%--------------------------------------------
%
% Package pgfplots
%
% Provides a user-friendly interface to create function plots (normal
% plots, semi-logplots and double-logplots).
% 
% It is based on Till Tantau's PGF package.
%
% Copyright 2007/2008/2009 by Christian Feuersänger.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------

\edef\pgfplots@oldcatcodesemicolon{\the\catcode`\;}%
\catcode`\;=12

\input pgfplotscore.code.tex
\input pgfplotslibrary.code.tex
\input pgfplotsoldpgfsupp_loader.code.tex
\input pgfplotsutil.code.tex
\input pgfplotscolormap.code.tex
\input pgfplotsstackedplots.code.tex
\input pgfplotscoordprocessing.code.tex
\input pgfplotsticks.code.tex



\usetikzlibrary{decorations,decorations.pathmorphing,decorations.pathreplacing}

% FIXME: reduce number of variables!

\newif\ifpgfplots@bb@isactive
\newif\ifpgfplots@xislinear
\newif\ifpgfplots@has@label@information
\newif\ifpgfplots@yislinear
\newif\ifpgfplots@zislinear
\newif\ifpgfplots@axis@equal
\newif\ifpgfplots@axis@equal@image
\newif\ifpgfplots@reverse@legend
\newif\ifpgfplots@transpose@legend
\newif\ifpgfplots@allow@reversal@of@rel@axis@cs
\newif\ifpgfplots@scanline@verbose
\newcount\pgfplots@numplots
\newdimen\pgfplots@xmin@reg
\newdimen\pgfplots@xmax@reg
\newdimen\pgfplots@ymin@reg
\newdimen\pgfplots@ymax@reg
\newdimen\pgfplots@zmin@reg
\newdimen\pgfplots@zmax@reg
\newif\ifpgfplots@warn@for@filter@discards
\newif\ifpgfplots@isuniformtick
\newif\ifpgfplots@clip@limits
\newif\ifpgfplots@clip
\newif\ifpgfplots@plot@coords@mathparser
\pgfplots@plot@coords@mathparsertrue
\pgfplots@cliptrue
\newif\ifpgfplots@enlargelimits
\newif\ifpgfplots@enlargelimits@rel@thresh
\newif\ifpgfplots@enlargelimits@auto
\newif\ifpgfplots@tickshow
\newif\ifpgfplots@scatterplotenabled
\newif\ifpgfplots@xminorticks
\newif\ifpgfplots@xmajorticks
\newif\ifpgfplots@yminorticks
\newif\ifpgfplots@ymajorticks
\newif\ifpgfplots@zminorticks
\newif\ifpgfplots@zmajorticks
\newif\ifpgfplots@xminorgrids
\newif\ifpgfplots@xmajorgrids
\newif\ifpgfplots@yminorgrids
\newif\ifpgfplots@ymajorgrids
\newif\ifpgfplots@zminorgrids
\newif\ifpgfplots@zmajorgrids
\newif\ifpgfplots@clip@marker@paths
\newif\ifpgfplots@axis@on@top
\newif\ifpgfplots@separate@axis@lines
\newif\ifpgfplots@identify@log@minor@tick@pos
\newif\ifpgfplots@disablelogfilter@x
\newif\ifpgfplots@disablelogfilter@y
\newif\ifpgfplots@disablelogfilter@z
\newif\ifpgfplots@disabledatascaling
\newif\ifpgfplots@hide@x
\newif\ifpgfplots@hide@y
\newif\ifpgfplots@hide@z
\newif\ifpgfplots@shownothingof@x
\newif\ifpgfplots@shownothingof@y
\newif\ifpgfplots@shownothingof@z
\newif\ifpgfplots@is@old@list@format
\newif\ifpgfplots@errorbars@enabled
\newif\ifpgfplots@scale@only@axis
\newif\ifpgfplots@xticklabel@interval
\newif\ifpgfplots@yticklabel@interval
\newif\ifpgfplots@zticklabel@interval
\newif\ifpgfplots@stackedmode
\newif\ifpgfplots@stacked@reverse
\newif\ifpgfplots@stacked@plus
\newif\ifpgfplots@plot@file@skipfirst
\newif\ifpgfplots@threedim
\newif\ifpgfplotsthreedim
\newif\ifpgfplots@curplot@isirrelevant
\newif\ifpgfplots@colorbar
\newif\ifpgfplots@deprecated@anchors
\newif\ifpgfplots@translategnuplot
\pgfplots@translategnuplottrue
\let\pgfnodepartimagebox=\pgfnodeparttextbox

\newif\ifpgfplots@collect@firstplot@astick
\newif\ifpgfplots@units@use

\def\pgfplots@errorbars@xdirection{0}% pre-init, see below
\def\pgfplots@errorbars@ydirection{0}%
\def\pgfplots@errorbars@zdirection{0}%

\def\axisdefaultwidth{240pt}
\def\axisdefaultheight{207pt}


% Invokes '#2' if a cycle list named '#1' exists and '#3' if not.
\long\def\pgfplotsifcyclelistexists#1#2#3{%
	\pgfutil@ifundefined{pgfp@cyclist@\string#1@}{#3}{#2}%
}%

% Creates a named plot cycle list.
%
% #1:  the name of the final list. Can be used in 'cycle list name'
% #2:  the list entries. You can use either a comma-separated list or
%      a '\\'-terminated list. The latter case also requires '\\'
%      AFTER the last entry.
\def\pgfplotscreateplotcyclelist#1#2{\expandafter\pgfplots@assign@list\csname pgfp@cyclist@\string#1@\endcsname{#2}}

\pgfplotscreateplotcyclelist{black white}{%
	every mark/.append style={fill=gray},mark=*\\%
	every mark/.append style={fill=gray},mark=square*\\%
	every mark/.append style={fill=gray},mark=otimes*\\%
	mark=star\\%
	every mark/.append style={fill=gray},mark=diamond*\\%
	densely dashed,every mark/.append style={solid,fill=gray},mark=*\\%
	densely dashed,every mark/.append style={solid,fill=gray},mark=square*\\%
	densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\%
	densely dashed,every mark/.append style={solid},mark=star\\%
	densely dashed,every mark/.append style={solid,fill=gray},mark=diamond*\\%
}

\pgfplotscreateplotcyclelist{color}{%
	blue,every mark/.append style={fill=blue!80!black},mark=*\\%
	red,every mark/.append style={fill=red!80!black},mark=square*\\%
	brown!60!black,every mark/.append style={fill=brown!80!black},mark=otimes*\\%
	black,mark=star\\%
	blue,every mark/.append style={fill=blue!80!black},mark=diamond*\\%
	red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\%
	brown!60!black,densely dashed,every mark/.append style={solid,fill=brown!80!black},mark=square*\\%
	black,densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\%
	blue,densely dashed,mark=star,every mark/.append style=solid\\%
	red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\%
}
\pgfplotscreateplotcyclelist{linestyles}{solid,dashed,dotted}
\pgfplotscreateplotcyclelist{color list}{red,blue,black,yellow,brown,teal,orange,violet,cyan,green!70!black,magenta,gray}
\pgfplotscreateplotcyclelist{mark list}{%
	every mark/.append style={fill=.!80!black},mark=*\\%
	every mark/.append style={fill=.!80!black},mark=square*\\%
	every mark/.append style={fill=.!80!black},mark=triangle*\\%
	mark=star\\%
	every mark/.append style={fill=.!80!black},mark=diamond*\\%
	every mark/.append style={fill=.!80!black},mark=otimes*\\%
	mark=|\\%
	every mark/.append style={fill=.!80!black},mark=pentagon*\\%
	mark=text,text mark=p\\%
	mark=text,text mark=a\\%
}
\pgfplotscreateplotcyclelist{exotic}{%
	teal,every mark/.append style={fill=teal!80!black},mark=*\\%
	orange,every mark/.append style={fill=orange!80!black},mark=square*\\%
	cyan!60!black,every mark/.append style={fill=cyan!80!black},mark=otimes*\\%
	red!70!white,mark=star\\%
	lime!80!black,every mark/.append style={fill=lime},mark=diamond*\\%
	red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\%
	yellow!60!black,densely dashed,every mark/.append style={solid,fill=yellow!80!black},mark=square*\\%
	black,every mark/.append style={solid,fill=gray},mark=otimes*\\%
	blue,densely dashed,mark=star,every mark/.append style=solid\\%
	red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\%
}


% backwards compatibility:
\let\pgfcreateplotcyclelist=\pgfplotscreateplotcyclelist
\pgfplots@letcsname{pgfp@cyclist@\string\blackwhiteplotspeclist @}={pgfp@cyclist@black white@}%
\pgfplots@letcsname{pgfp@cyclist@\string\coloredplotspeclist @}={pgfp@cyclist@color@}%
%%%%

\def\pgfplotsset#{\pgfqkeys{/pgfplots}}

\def\pgfplotsdeprecatedstylecheck#1{%
	\pgfkeysifdefined{#1/.@cmd}{%
		\begingroup
		\edef\pgfkeyscurrentkey{#1}%
		\pgfkeyssplitpath
		\pgfplots@warning{Loading deprecated style option 
			\pgfkeyscurrentpath/\pgfkeyscurrentname.  
			Please replace '\string\tikzstyle{\pgfkeyscurrentname}' 
			with '\string\pgfplotsset{\pgfkeyscurrentname/.style={}}'
			(or '\string\pgfplotsset{\pgfkeyscurrentname/.append style={}}').}%
		\endgroup
		\pgfkeysvalueof{#1/.@cmd}\pgfeov
	}{}%
}%

\def\pgfplots@scaled@ticks@setargs#1#2{%
	\pgfutil@in@{:}{#2}%
	\ifpgfutil@in@
		\pgfplots@scaled@ticks@setargs@{#1}#2\pgfplots@EOI
	\else
		\expandafter\pgfutil@in@\expandafter{\pgfplots@activecolon}{#2}%
		\ifpgfutil@in@
			\pgfplots@scaled@ticks@setargs@active{#1}#2\pgfplots@EOI
		\else
			\pgfkeysalso{/pgfplots/scaled #1 ticks/#2}%
		\fi
	\fi
}%
\def\pgfplots@scaled@ticks@setargs@#1#2:#3\pgfplots@EOI{%
	\pgfkeysalso{/pgfplots/scaled #1 ticks/#2=#3}%
}

{
	\catcode`\:=\active
	\gdef\pgfplots@scaled@ticks@setargs@active#1#2:#3\pgfplots@EOI{%
		\pgfkeysalso{/pgfplots/scaled #1 ticks/#2=#3}%
	}
}

\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@center\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south west\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@south east\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@east\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north east\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@north west\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@west\endcsname{1}
\expandafter\def\csname pgfplots@nodesnearcoordsalign@isanchor@baseline\endcsname{1}

% Sets the keys for /pgfplots/[xyz]ticklabel anchor.
% #1: one of [xyz]
% #2: the value
\def\pgfplots@setticklabel@anchor@for#1#2{%
	\def\pgfplots@loc@TMPa{#2}%
	\def\pgfplots@loc@TMPb{auto}%
	\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
		\expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{0}%
	\else
		\def\pgfplots@loc@TMPb{near ticklabel}%
		\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
			\expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{1}%
		\else
			\def\pgfplots@loc@TMPb{tikz}%
			\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				\expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{2}%
			\else
				\pgfplots@error{Sorry, I got an unexpected value for '#1ticklabel anchor': '#2'. Expected one of 'auto', 'near ticklabel' or 'tikz'.}%
			\fi
		\fi
	\fi
}%

% Does the work for '[xyz]ticklabel pos'.
%
% #1: the axis (x,y or z).
% #2: the key argument. Accepts 
% 	'lower',
% 	'upper',
% 	'default' -> depends on 'tick pos'
% 	'left' = 'lower',
% 	'bottom' = 'lower',
% 	'right' = 'upper'
% 	'top' = 'upper'.
%
\def\pgfplots@setkey@ticklabelpos#1#2{%
	\def\pgfplots@loc@TMPa{#2}%
	\def\pgfplots@loc@TMPb{lower}%
	\expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{l}%
	\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
	\else
		\def\pgfplots@loc@TMPb{upper}%
		\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
			\expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}%
		\else
			\def\pgfplots@loc@TMPb{default}%
			\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				\expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{}%
			\else
				\def\pgfplots@loc@TMPb{left}%
				\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				\else
					\def\pgfplots@loc@TMPb{right}%
					\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
						\expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{u}%
					\else
						\expandafter\def\csname pgfplots@#1ticklabel@pos\endcsname{}%
						\pgfplots@error{Sorry, the key '#1ticklabel pos' does not know what to do with '#2'... accepted values are 'default, 'lower', 'upper' and some aliases. Maybe you misspelled it?}%
					\fi
				\fi
			\fi
		\fi
	\fi
}%

% Sets 'x dir={normal,reverse}'
% #1: an axis
% #2: the key's value to apply
\def\pgfplots@setkey@axisdir@for#1#2{%
	\def\pgfplots@loc@TMPa{#2}%
	\def\pgfplots@loc@TMPb{normal}%
	\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
		\pgfkeyssetvalue{/pgfplots/#1 dir/value}{n}%
	\else
		\def\pgfplots@loc@TMPb{reverse}%
		\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
			\pgfkeyssetvalue{/pgfplots/#1 dir/value}{r}%
		\else
			\pgfkeyssetvalue{/pgfplots/#1 dir/value}{n}%
			\pgfplots@error{Sorry, the key '#1 dir' does not know what to do with '#2'... accepted values are 'normal' or 'reverse'.}%
		\fi
	\fi
}%


\def\pgfplots@meshmode{n}% none
\def\pgfplotsplothandlermesh@flatmode{m}% mean

\def\pgfplots@cycle@multi@list@EOI{\pgfplots@cycle@multi@list@EOI}%
\def\pgfplots@cycle@multi@list#1{%
	\def\pgfplots@loc@TMPb{0}%
	\gdef\pgfplots@cycle@multi@list@finalize@{}%
	\pgfplots@cycle@multi@list@#1\nextlist\pgfplots@cycle@multi@list@EOI
}%
\def\pgfplots@cycle@multi@list@#1\nextlist{%
	\def\pgfplots@loc@TMPa{#1}%
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
		% ignore it if someone provided too many \nextlist commands.
	\else
		% parse and store list:
		\begingroup
			\def\pgfplots@as@string{#1}% this deals with control sequences inside of #1.
			\pgfplots@command@to@string\pgfplots@as@string\pgfplots@as@string
			\expandafter\pgfplots@cycle@multi@list@findnamed\pgfplots@as@string\pgfplots@EOI
			\global\let\pgfplots@glob@TMPa=\pgfplots@loc@TMPa
		\endgroup
		\ifx\pgfplots@glob@TMPa\pgfutil@empty
			% create it:
			\pgfplotscreateplotcyclelist{/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb}{#1}%
		\else
			% ok, take an existing one
			\expandafter\let\csname pgfp@cyclist@/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb @\endcsname=\pgfplots@glob@TMPa
		\fi
		\begingroup
			\expandafter\pgfplotslistsize\csname pgfp@cyclist@/pgfplots/cycle multi list/@list\pgfplots@loc@TMPb @\endcsname\to\c@pgf@counta
			\edef\pgfmathresult{\the\c@pgf@counta}%
			\pgfmath@smuggleone\pgfmathresult
		\endgroup
		\pgfkeyslet{/pgfplots/cycle multi list/@totalN\pgfplots@loc@TMPb}\pgfmathresult
		\pgfkeyslet{/pgfplots/cycle multi list/@N\pgfplots@loc@TMPb}\pgfmathresult
%\def\temp{#1}\message{cycle multi list/@list={\meaning\temp};   /@N\pgfplots@loc@TMPb = \pgfkeysvalueof{/pgfplots/cycle multi list/@N\pgfplots@loc@TMPb}.}%
		\pgfplotsutil@advancestringcounter\pgfplots@loc@TMPb
	\fi
	%
	\pgfutil@ifnextchar{\pgfplots@cycle@multi@list@EOI}{%
		\pgfplots@cycle@multi@list@finalize
	}{%
		\pgfplots@cycle@multi@list@
	}%
}%

% checks for 
% - <known list>
% - [<elements> of]<known list>
% POSTCONDITION:
% 	1. pgfplots@loc@TMPa will be \pgfutil@empty if there is no such
% 	list.
% 	2. \pgfplots@loc@TMPa will be \let to the list if there is one.
% 	3. \pgfplots@cycle@multi@list@finalize@ will contain any 'partial sublist'
% 	commands.
\def\pgfplots@cycle@multi@list@findnamed{\pgfutil@ifnextchar[{\pgfplots@cycle@multi@list@findnamed@}{\pgfplots@cycle@multi@list@findnamed@[]}}%
\def\pgfplots@cycle@multi@list@findnamed@[#1]#2\pgfplots@EOI{%
	\def\pgfplots@loc@TMPa{#1}%
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
	\else
		\pgfplots@cycle@multi@list@findnamed@@#1 \pgfplots@EOI
	\fi
	\pgfplotsifcyclelistexists{#2}{%
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@cyclist@\string#2@\endcsname%
	}{%
		\let\pgfplots@loc@TMPa=\pgfutil@empty
	}%
}
\def\pgfplots@cycle@multi@list@findnamed@@#1 {\pgfutil@ifnextchar o{\pgfplots@cycle@multi@list@findnamed@@@{#1}}{\pgfplots@cycle@multi@list@findnamed@@@{#1}of}}%
\def\pgfplots@cycle@multi@list@findnamed@@@#1of#2\pgfplots@EOI{%
	\begingroup
		\t@pgfplots@toka=\expandafter{\pgfplots@cycle@multi@list@finalize@}%
		\t@pgfplots@tokb={#1}%
		\xdef\pgfplots@cycle@multi@list@finalize@{\the\t@pgfplots@toka
			\noexpand\pgfkeys{/pgfplots/cycle multi list/partial sublist={\pgfplots@loc@TMPb}{\the\t@pgfplots@tokb}}%
		}%
	\endgroup
}

\def\pgfplots@cycle@multi@list@finalize\pgfplots@cycle@multi@list@EOI{%
	\pgfkeyslet{/pgfplots/cycle multi list/@dim}\pgfplots@loc@TMPb
	\pgfplots@cycle@multi@list@finalize@
}%

\def\pgfplots@pgfkeys@set@point@meta@value#1{%
	%
	\pgfutil@in@{=}{#1}%
	\ifpgfutil@in@
		\def\pgfplots@loc@TMPa##1=##2\pgfplots@EOI{%
			% remove spaces from ##1 and ##2:
			\pgfkeys@spdef\pgfplots@loc@TMPa{##1}%
			\pgfkeys@spdef\pgfplots@loc@TMPb{##2}%
			% 
			% check if the argument is known:
			\pgfkeysifdefined{/pgfplots/point meta/\pgfplots@loc@TMPa/.@cmd}{%
				\def\pgfplots@loc@TMPc{%
					\pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/\pgfplots@loc@TMPa/.@cmd}%
				}%
				\expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPb}%
			}{%
				\pgfplotsthrow{invalid argument}
					{\pgfplots@loc@TMPa}%
					{Sorry, `##1' is no valid choice for `point meta'. Maybe you misspelled it?}%
					\pgfeov
			}%
		}%
		% disassemble key'='value:
		\pgfplots@loc@TMPa#1\pgfplots@EOI
	\else
		% the following code allows
		% 'point meta=\thisrow{xcol}' even though
		% \thisrow might be undefined in the context where keys are set.
		% I convert the argument to a string.
		\def\pgfplots@loc@TMPa{#1}%
		\pgfplots@command@to@string\pgfplots@loc@TMPa\pgfplots@loc@TMPb
		%
		\pgfkeysifdefined{/pgfplots/point meta/\pgfplots@loc@TMPb/.@cmd}{%
			% ok, use it!
			\pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/\pgfplots@loc@TMPb/.@cmd}{}%
		}{%
			% oh, then it will be a math expression.
			\pgfplots@invoke@pgfkeyscode{/pgfplots/point meta/expr/.@cmd}{#1}%
		}%
	\fi
	%
	%
}%

\pgfkeys{%
	/pgfplots/search path for tikz/.search also={/tikz,/pgfplots},
	/pgfplots/.is family,
	/pgfplots/scale/.is family,
	/pgfplots/legend/.is family,
	/pgfplots/tick/.is family,
	/pgfplots/axis/.is family,
	/pgfplots/descriptions/.is family,
	/pgfplots/style commands/.is family,
	/pgfplots/naming commands/.is family,
	/pgfplots/shared with tikz/.is family,
	/pgfplots/error bars/.is family,
	/pgfplots/every axis/.style={},
	/pgfplots/every axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis}},
	/pgfplots/every axis/.belongs to family=/pgfplots/style commands,
	/pgfplots/every semilogx axis/.style={},
	/pgfplots/every semilogx axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogx axis}},
	/pgfplots/every semilogx axis/.belongs to family=/pgfplots/style commands,
	/pgfplots/every semilogy axis/.style={},
	/pgfplots/every semilogy axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every semilogy axis}},
	/pgfplots/every semilogy axis/.belongs to family=/pgfplots/style commands,
	/pgfplots/every loglog axis/.style={},
	/pgfplots/every loglog axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every loglog axis}},
	/pgfplots/every loglog axis/.belongs to family=/pgfplots/style commands,
	/pgfplots/every linear axis/.style={},
	/pgfplots/every linear axis/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every linear axis}},
	/pgfplots/every linear axis/.belongs to family=/pgfplots/style commands,
	/pgfplots/every axis plot/.style={},
	/pgfplots/every axis plot/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}},
	/pgfplots/every axis plot/.belongs to family=/pgfplots/style commands,
	/pgfplots/every axis plot post/.style={},
	/pgfplots/every axis plot post/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis plot}},
	/pgfplots/no marks/.style={/pgfplots/no markers},
	/pgfplots/no markers/.style={/pgfplots/every axis plot post/.append style={mark=none}},
	/pgfplots/every axis label/.style={},
	/pgfplots/every axis label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis label}},
	/pgfplots/every axis label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/xlabel near ticks/.style={%
		/pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},%
		/pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.9,5pt)},anchor=near xticklabel,inner sep=0pt},
	},%
	/pgfplots/xlabel absolute/.style={%
		/pgfplots/every axis x label/.style={at={(0.5,0)},below,yshift=-15pt},%
		/pgfplots/every x tick scale label/.style={at={(1,0)},yshift=-2em,left,inner sep=0pt},
	},%
	/pgfplots/every axis x label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis x label}},
	/pgfplots/every axis x label/.belongs to family=/pgfplots/descriptions,
	%
	/pgfplots/ylabel near ticks/.style={%
		/pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},%
		/pgfplots/every y tick scale label/.style={at={(yticklabel cs:1.03,-\pgfplotsvalueoflargesttickdimen y -0.3em)},anchor=south west,inner sep=0pt},
	},%
	/pgfplots/ylabel absolute/.style={%
		/pgfplots/every axis y label/.style={at={(0,0.5)},xshift=-35pt,rotate=90},
		/pgfplots/every y tick scale label/.style={at={(0,1)},above right,inner sep=0pt,yshift=0.3em},
	},%
	/pgfplots/every axis y label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis y label}},
	/pgfplots/every axis y label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every axis z label/.style={at={(ticklabel cs:0.5)},rotate=90, anchor=near ticklabel},
	/pgfplots/every axis z label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis z label}},
	/pgfplots/every axis z label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every 3d description/.style={%
		/pgfplots/every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},%
		/pgfplots/every axis y label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},%
		/pgfplots/every x tick scale label/.style={at={(xticklabel cs:0.95,5pt)},anchor=near xticklabel,inner sep=0pt},
		/pgfplots/every y tick scale label/.style={at={(yticklabel cs:0.95,5pt)},anchor=near yticklabel,inner sep=0pt},
		/pgfplots/try min ticks=3,%
	},%
	/pgfplots/every 3d view {0}{90}/.style={%
		/pgfplots/xlabel near ticks,%
		/pgfplots/ylabel near ticks,%
		/pgfplots/axis on top=true,%
	},%
	% will be defined in \pgfplotspoint@initialisation:
	%/tikz/sloped like x axis/.code={...},%
	/pgfplots/title shift/.code={\pgfplots@error{Sorry, there is no 'title shift' option. Consider using 'title style={yshift=...}' (or the low level 'every axis title shift' which works only together with the initial 'every axis title' style)}},%
	/pgfplots/every axis title shift/.initial=6pt,
	/pgfplots/every axis title/.style={at={(0.5,1)},above,yshift=\pgfkeysvalueof{/pgfplots/every axis title shift}},
	/pgfplots/every axis title/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis title}},
	/pgfplots/every axis title/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every tick/.style={very thin,gray},
	/pgfplots/every tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every tick}},
	/pgfplots/every tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every inner x axis line/.style={},
	/pgfplots/every inner y axis line/.style={},
	/pgfplots/every inner z axis line/.style={},
	/pgfplots/every outer x axis line/.style={},
	/pgfplots/every outer y axis line/.style={},
	/pgfplots/every outer z axis line/.style={},
	/pgfplots/x axis line style/.style={
		/pgfplots/every outer x axis line/.append style={#1},
		/pgfplots/every inner x axis line/.append style={#1},
	},
	/pgfplots/y axis line style/.style={
		/pgfplots/every outer y axis line/.append style={#1},
		/pgfplots/every inner y axis line/.append style={#1},
	},
	/pgfplots/z axis line style/.style={
		/pgfplots/every outer z axis line/.append style={#1},
		/pgfplots/every inner z axis line/.append style={#1},
	},
	/pgfplots/outer axis line style/.style={
		/pgfplots/every outer x axis line/.append style={#1},
		/pgfplots/every outer y axis line/.append style={#1}%
		/pgfplots/every outer z axis line/.append style={#1}%
	},
	/pgfplots/inner axis line style/.style={
		/pgfplots/every inner x axis line/.append style={#1},
		/pgfplots/every inner y axis line/.append style={#1}%
		/pgfplots/every inner z axis line/.append style={#1}%
	},
	/pgfplots/axis line style/.style={
		/pgfplots/inner axis line style={#1},
		/pgfplots/outer axis line style={#1}%
	},
	/pgfplots/separate axis lines/.is if=pgfplots@separate@axis@lines,
	/pgfplots/separate axis lines/.default=true,
	/pgfplots/every minor tick/.style={},
	/pgfplots/every minor tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor tick}},
	/pgfplots/every minor tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major tick/.style={},
	/pgfplots/every major tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major tick}},
	/pgfplots/every major tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every x tick/.style={},
	/pgfplots/every x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick}},
	/pgfplots/every x tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor x tick/.style={},
	/pgfplots/every minor x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x tick}},
	/pgfplots/every minor x tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major x tick/.style={},
	/pgfplots/every major x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x tick}},
	/pgfplots/every major x tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every y tick/.style={},
	/pgfplots/every y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick}},
	/pgfplots/every y tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor y tick/.style={},
	/pgfplots/every minor y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y tick}},
	/pgfplots/every minor y tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major y tick/.style={},
	/pgfplots/every major y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y tick}},
	/pgfplots/every major y tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every z tick/.style={},
	/pgfplots/every z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every z tick}},
	/pgfplots/every z tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor z tick/.style={},
	/pgfplots/every minor z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor z tick}},
	/pgfplots/every minor z tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major z tick/.style={},
	/pgfplots/every major z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major z tick}},
	/pgfplots/every major z tick/.belongs to family=/pgfplots/style commands,
	%/pgfplots/every axis grid/.style={help lines},
	/pgfplots/every axis grid/.style={thin,black!25},
	/pgfplots/every axis grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis grid}},
	/pgfplots/every axis grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor grid/.style={},
	/pgfplots/every minor grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor grid}},
	/pgfplots/every minor grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major grid/.style={},
	/pgfplots/every major grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major grid}},
	/pgfplots/every major grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every axis x grid/.style={},
	/pgfplots/every axis x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis x grid}},
	/pgfplots/every axis x grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor x grid/.style={},
	/pgfplots/every minor x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor x grid}},
	/pgfplots/every minor x grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major x grid/.style={},
	/pgfplots/every major x grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major x grid}},
	/pgfplots/every major x grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every axis y grid/.style={},
	/pgfplots/every axis y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis y grid}},
	/pgfplots/every axis y grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor y grid/.style={},
	/pgfplots/every minor y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor y grid}},
	/pgfplots/every minor y grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major y grid/.style={},
	/pgfplots/every major y grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major y grid}},
	/pgfplots/every major y grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every axis z grid/.style={},
	/pgfplots/every axis z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis z grid}},
	/pgfplots/every axis z grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every minor z grid/.style={},
	/pgfplots/every minor z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every minor z grid}},
	/pgfplots/every minor z grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every major z grid/.style={},
	/pgfplots/every major z grid/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every major z grid}},
	/pgfplots/every major z grid/.belongs to family=/pgfplots/style commands,
	/pgfplots/every tick label/.style={},
	/pgfplots/every tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every tick label}},
	/pgfplots/every tick label/.belongs to family=/pgfplots/style commands,
	/pgfplots/every x tick label/.style={},
	/pgfplots/every x tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick label}},
	/pgfplots/every x tick label/.belongs to family=/pgfplots/style commands,
	/pgfplots/every extra x tick/.style={
		/pgfplots/log identify minor tick positions=true,
	},
	/pgfplots/every extra x tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra x tick}},
	/pgfplots/every extra x tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra x tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra x tick style/.code={%
		\pgfkeysalso{/pgfplots/every extra x tick/.append style={#1}}%
	},
	/pgfplots/extra tick style/.code={%
		\pgfkeysalso{%
			/pgfplots/every extra x tick/.append style={#1},%
			/pgfplots/every extra y tick/.append style={#1},%
			/pgfplots/every extra z tick/.append style={#1}}%
	},
	/pgfplots/every x tick scale label/.initial=,% set by compat/labels=...
	/pgfplots/every x tick scale label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every x tick scale label}},
	/pgfplots/every x tick scale label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every y tick label/.style={},
	/pgfplots/every y tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick label}},
	/pgfplots/every y tick label/.belongs to family=/pgfplots/style commands,
	/pgfplots/every extra y tick/.style={
		/pgfplots/log identify minor tick positions=true,
	},
	/pgfplots/every extra y tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra y tick}},
	/pgfplots/every extra y tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra y tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra y tick style/.code={%
		\pgfkeysalso{/pgfplots/every extra y tick/.append style={#1}}%
	},
	/pgfplots/every y tick scale label/.initial=,% set by compat/labels=...
	/pgfplots/every y tick scale label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every y tick scale label}},
	/pgfplots/every y tick scale label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every z tick label/.style={},
	/pgfplots/every z tick label/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every z tick label}},
	/pgfplots/every z tick label/.belongs to family=/pgfplots/style commands,
	/pgfplots/every extra z tick/.style={
		/pgfplots/log identify minor tick positions=true,
	},
	/pgfplots/every extra z tick/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every extra z tick}},
	/pgfplots/every extra z tick/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra z tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/extra z tick style/.code={%
		\pgfkeysalso{/pgfplots/every extra z tick/.append style={#1}}%
	},
	/pgfplots/every z tick scale label/.style={at={(zticklabel cs:1.2,-\pgfplotsvalueoflargesttickdimen z -0.3em)},anchor=near zticklabel,inner sep=0pt},
	/pgfplots/every z tick scale label/.belongs to family=/pgfplots/descriptions,
	/pgfplots/every axis legend/.style={%
		cells={anchor=center},
		inner xsep=3pt,inner ysep=2pt,nodes={inner sep=2pt,text depth=0.15em},
		anchor=north east,%
		shape=rectangle,%
		fill=white,%
		draw=black,
		at={(0.98,0.98)},
	},
	/pgfplots/every axis legend/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every axis legend}},
	/pgfplots/every axis legend/.belongs to family=/pgfplots/style commands,
	%
	% Colorbar interface:
	/pgfplots/colorbar/.is if=pgfplots@colorbar,
	/pgfplots/colorbar/.default=true,
	/pgfplots/colorbar to label/.style={/pgfplots/colorbar to name={#1}},
	/pgfplots/colorbar to name/.initial=,
	/pgfplots/colorbar source/.code={\pgfplots@error{Sorry, you can only set `colorbar source' inside of \string\addplot\space (or a cycle list)}},
	/pgfplots/colorbar source/.default=true,
	/pgfplots/colorbar pos*/.initial=,% one of 'rltb' (right, left, top, bottom). for internal use, to handle checks.
	/pgfplots/colorbar right/.style={%
		/pgfplots/colorbar=true,
		/pgfplots/colorbar pos*=r,
		/pgfplots/colorbar shift/.style={xshift=0.3cm},
		/pgfplots/every colorbar/.style={%
			title=,
			xlabel=,
			ylabel=,
			zlabel=,
			legend entries=,
			axis on top,
			at={(parent axis.right of north east)},
			anchor=north west,
			grid=none,
			xmin=0,
			xmax=1,
			ymin=\pgfkeysvalueof{/pgfplots/point meta min},
			ymax=\pgfkeysvalueof{/pgfplots/point meta max},
			plot graphics/xmin=0,%
			plot graphics/xmax=1,
			plot graphics/ymin=\pgfkeysvalueof{/pgfplots/point meta min},
			plot graphics/ymax=\pgfkeysvalueof{/pgfplots/point meta max},
			enlargelimits=false,
			scale only axis,
			height=\pgfkeysvalueof{/pgfplots/parent axis height},%
			width=\pgfkeysvalueof{/pgfplots/colorbar/width},
			xtick=\empty,
			xticklabel=,
			ytick=,
			yticklabel=,
			yticklabel pos=right,% ATTENTION: I check for this setting in 'colorbar sampled line', see below!
			colorbar vertical/lowlevel,
		}%
	},%
	/pgfplots/colorbar left/.style={%
		/pgfplots/colorbar right,
		/pgfplots/colorbar pos*=l,
		/pgfplots/colorbar shift/.style={xshift=-0.3cm},
		/pgfplots/every colorbar/.append style={%
			at={(parent axis.left of north west)},
			anchor=north east,
			yticklabel pos=left,% ATTENTION: I check for this setting in 'colorbar sampled line', see below!
		}%
	},%
	/pgfplots/colorbar horizontal/.style={%
		/pgfplots/colorbar=true,
		/pgfplots/colorbar pos*=b,
		/pgfplots/colorbar shift/.style={yshift=-0.3cm},
		/pgfplots/every colorbar/.style={%
			title=,
			xlabel=,
			ylabel=,
			zlabel=,
			legend entries=,
			axis on top,
			at={(parent axis.below south west)},
			anchor=north west,
			grid=none,
			ymin=0,
			ymax=1,
			xmin=\pgfkeysvalueof{/pgfplots/point meta min},
			xmax=\pgfkeysvalueof{/pgfplots/point meta max},
			plot graphics/ymin=0,%
			plot graphics/ymax=1,
			plot graphics/xmin=\pgfkeysvalueof{/pgfplots/point meta min},
			plot graphics/xmax=\pgfkeysvalueof{/pgfplots/point meta max},
			enlargelimits=false,
			scale only axis,
			width=\pgfkeysvalueof{/pgfplots/parent axis width},%
			height=\pgfkeysvalueof{/pgfplots/colorbar/width},
			xticklabel pos=left,
			xtick=,
			xticklabel=,
			ytick=\empty,
			colorbar horizontal/lowlevel,
		}%
	},%
	% You might wonder why this special treatment with '/lowlevel'
	% keys is necessary. Well, It turned out that using '##' inside of
	% styles is incompatible with '.add code' -- and therefor also
	% with '.append style'. This here is a work-around which works.
	/pgfplots/colorbar vertical/lowlevel/.style={%
		/pgfplots/colorbar addplot=\addplot graphics {};,
		plot graphics/lowlevel draw/.code 2 args={%
			\if\pgfkeysvalueof{/pgfplots/y dir/value}n%
				\pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa
			\else
				\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##2}\pgfplots@loc@TMPa
			\fi
			\def\pgfplots@loc@TMPb{\pgfdeclareverticalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
			\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
			\pgfuseshading{tempshading}%
		},%
	},
	/pgfplots/colorbar horizontal/lowlevel/.style={%
		/pgfplots/colorbar addplot=\addplot graphics {};,
		plot graphics/lowlevel draw/.code 2 args={%
			\if\pgfkeysvalueof{/pgfplots/x dir/value}n%
				\pgfplotscolormaptoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa
			\else
				\pgfplotscolormapreversedtoshadingspec{\pgfkeysvalueof{/pgfplots/colormap name}}{##1}\pgfplots@loc@TMPa
			\fi
			\def\pgfplots@loc@TMPb{\pgfdeclarehorizontalshading{tempshading}{\pgfkeysvalueof{/pgfplots/colorbar/width}}}%
			\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
			\pgfuseshading{tempshading}%
		},%
	},%
	/pgfplots/colorbar right,
	/pgfplots/colorbar=false,
	/pgfplots/colorbar style/.style={/pgfplots/every colorbar/.append style={#1}},
	/pgfplots/colorbar/width/.initial=0.5cm,
	/pgfplots/colorbar addplot/.initial=\addplot graphics {};,
	/pgfplots/colorbar/draw/.code={%
		% FIXME : the semicolon after ';' has a fixed catcode, namely
		% the one assigned while pgfplots.code.tex has been read.
		%
		% The \pgfplots@checkandpreparefor@active@semicolon gets
		% confused if the catcodes change... this here is a
		% work-around for babel support.
		\let\pgfplots@checkandpreparefor@active@semicolon=\relax
		\axis[every colorbar,colorbar shift,colorbar=false]
		\pgfkeysvalueof{/pgfplots/colorbar addplot}%
		\endaxis
	},%
	/pgfplots/every colorbar sampled line/.style={help lines},
	/pgfplots/colorbar sampled line style/.style={/pgfplots/every colorbar sampled line/.append style={#1}},
	/pgfplots/colorbar sampled line/.style={%
		colorbar,
		/pgfplots/colorbar/draw/.code={%
			\axis[
				cycle list={#1\\},
				domain=\pgfkeysvalueof{/pgfplots/point meta min}:\pgfkeysvalueof{/pgfplots/point meta max},
				every colorbar,colorbar shift,colorbar=false]
			\pgfkeysvalueof{/pgfplots/colorbar addplot}%
			\endaxis
		},%
		/pgfplots/colorbar horizontal/lowlevel/.code={%
			\pgfkeysgetvalue{/pgfplots/colorbar pos*}\pgfplots@loc@TMPa
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
				\def\pgfplots@loc@TMPa{b}%
			\fi
			\if b\pgfplots@loc@TMPa
				\pgfkeysalso{axis x line*=bottom}% DEFAULT.
			\else
				\pgfkeysalso{axis x line*=top}%
			\fi
			\pgfkeysalso{%
				y axis line style={/pgfplots/every colorbar sampled line},
				/pgfplots/colorbar addplot={\addplot {0.5};},
				point meta=x,
			}%
		},%
		/pgfplots/colorbar vertical/lowlevel/.code={%
			\pgfkeysgetvalue{/pgfplots/colorbar pos*}\pgfplots@loc@TMPa
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
				\def\pgfplots@loc@TMPa{r}%
			\fi
			\if l\pgfplots@loc@TMPa
				\pgfkeysalso{axis y line*=left}%
			\else
				\pgfkeysalso{axis y line*=right}% DEFAULT
			\fi
			\pgfkeysalso{%
				x axis line style={/pgfplots/every colorbar sampled line},
				/pgfplots/colorbar addplot={\addplot (0.5,x);},
				point meta=y,
			}%
		},%
	},%
	/pgfplots/colorbar sampled line/.default={scatter,only marks},
	%
	/pgfplots/colorbar sampled/.style={%
		colorbar,
		/pgfplots/colorbar/draw/.code={%
			\axis[
				view={0}{90},
				cycle list={#1\\},
				domain=\pgfkeysvalueof{/pgfplots/point meta min}:\pgfkeysvalueof{/pgfplots/point meta max},
				samples y=2,
				domain y=0:1,
				zmin=0,zmax=1,
				every colorbar,colorbar shift,colorbar=false]
			\pgfkeysvalueof{/pgfplots/colorbar addplot}%
			\endaxis
		},%
		/pgfplots/colorbar horizontal/lowlevel/.style={%
			/pgfplots/colorbar addplot={\addplot3 {0};},
			point meta=x,
		},%
		/pgfplots/colorbar vertical/lowlevel/.style={%
			/pgfplots/colorbar addplot={\addplot3 (y,x,0);},
			point meta=y,
		},%
	},%
	/pgfplots/colorbar sampled/.default={surf,mark=none,shader=flat},
% tick options:
	/pgfplots/xticklabel/.store in=	\pgfplots@xticklabel,
	/pgfplots/xticklabel/.belongs to family=/pgfplots/tick,
	/pgfplots/xticklabel=,
	/pgfplots/xticklabels/.belongs to family=/pgfplots/tick,
	/pgfplots/xticklabels/.code={%
		\pgfplotslistnew\pgfplots@xticklabels{#1}%
		\let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x
	},
	% #1 table name or macro
	% #2 column name (or alias or create on use)
	/pgfplots/xticklabels from table/.code 2 args={%
		\pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@xticklabels
		\let\pgfplots@xticklabel=\pgfplots@user@ticklabel@list@x
	},
	/pgfplots/xticklabels from table/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabels/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabels/.code={%
		\pgfplotslistnew\pgfplots@yticklabels{#1}%
		\let\pgfplots@yticklabel=\pgfplots@user@ticklabel@list@y
	},
	% #1 table name or macro
	% #2 column name (or alias or create on use)
	/pgfplots/yticklabels from table/.code 2 args={%
		\pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@yticklabels
		\let\pgfplots@yticklabel=\pgfplots@user@ticklabel@list@y
	},
	/pgfplots/yticklabels from table/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabel/.store in=	\pgfplots@yticklabel,
	/pgfplots/yticklabel/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabel=,
	/pgfplots/zticklabels/.belongs to family=/pgfplots/tick,
	/pgfplots/zticklabels/.code={%
		\pgfplotslistnew\pgfplots@zticklabels{#1}%
		\let\pgfplots@zticklabel=\pgfplots@user@ticklabel@list@z
	},
	% #1 table name or macro
	% #2 column name (or alias or create on use)
	/pgfplots/zticklabels from table/.code 2 args={%
		\pgfplotstablegetcolumn{#2}\of{#1}\to\pgfplots@zticklabels
		\let\pgfplots@zticklabel=\pgfplots@user@ticklabel@list@z
	},
	/pgfplots/zticklabels from table/.belongs to family=/pgfplots/tick,
	/pgfplots/zticklabel/.store in=	\pgfplots@zticklabel,
	/pgfplots/zticklabel/.belongs to family=/pgfplots/tick,
	/pgfplots/zticklabel=,
	/pgfplots/x tick label as interval/.is if=pgfplots@xticklabel@interval,
	/pgfplots/x tick label as interval/.default=true,
	/pgfplots/x tick label as interval/.belongs to family=/pgfplots/tick,
	/pgfplots/y tick label as interval/.is if=pgfplots@yticklabel@interval,
	/pgfplots/y tick label as interval/.default=true,
	/pgfplots/y tick label as interval/.belongs to family=/pgfplots/tick,
	/pgfplots/z tick label as interval/.is if=pgfplots@zticklabel@interval,
	/pgfplots/z tick label as interval/.default=true,
	/pgfplots/z tick label as interval/.belongs to family=/pgfplots/tick,
	/pgfplots/extra x tick label/.store in=	\pgfplots@extra@xticklabel,
	/pgfplots/extra x tick label/.belongs to family=/pgfplots/tick,
	/pgfplots/extra x tick label=,
	/pgfplots/extra x tick labels/.belongs to family=/pgfplots/tick,
	/pgfplots/extra x tick labels/.code={%
		\pgfplotslistnew\pgfplots@extra@xticklabels{#1}%
		\let\pgfplots@extra@xticklabel=\pgfplots@user@extra@ticklabel@list@x
	},
	/pgfplots/extra y tick labels/.code={%
		\pgfplotslistnew\pgfplots@extra@yticklabels{#1}%
		\let\pgfplots@extra@yticklabel=\pgfplots@user@extra@ticklabel@list@y
	},
	/pgfplots/extra z tick labels/.code={%
		\pgfplotslistnew\pgfplots@extra@zticklabels{#1}%
		\let\pgfplots@extra@zticklabel=\pgfplots@user@extra@ticklabel@list@z
	},
	/pgfplots/xtick/.store in=			\pgfplots@xtick,
	/pgfplots/xtick/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick=,
	/pgfplots/extra x ticks/.store in=\pgfplots@extra@xtick,
	/pgfplots/extra x ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/extra x ticks=,
	/pgfplots/xtickten/.store in=		\pgfplots@xtickten,
	/pgfplots/xtickten/.belongs to family=/pgfplots/tick,
	/pgfplots/xtickten=,
	/pgfplots/extra y tick label/.store in=	\pgfplots@extra@yticklabel,
	/pgfplots/extra y tick label/.belongs to family=/pgfplots/tick,
	/pgfplots/extra y tick label=,
	/pgfplots/ytick/.store in=			\pgfplots@ytick,
	/pgfplots/ytick/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick=,
	/pgfplots/extra y ticks/.store in=\pgfplots@extra@ytick,
	/pgfplots/extra y ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/extra y ticks=,
	/pgfplots/ytickten/.store in=		\pgfplots@ytickten,
	/pgfplots/ytickten/.belongs to family=/pgfplots/tick,
	/pgfplots/ytickten=,
	/pgfplots/extra z tick label/.store in=	\pgfplots@extra@zticklabel,
	/pgfplots/extra z tick label/.belongs to family=/pgfplots/tick,
	/pgfplots/extra z tick label=,
	/pgfplots/ztick/.store in=			\pgfplots@ztick,
	/pgfplots/ztick/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick=,
	/pgfplots/extra z ticks/.store in=\pgfplots@extra@ztick,
	/pgfplots/extra z ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/extra z ticks=,
	/pgfplots/ztickten/.store in=		\pgfplots@ztickten,
	/pgfplots/ztickten/.belongs to family=/pgfplots/tick,
	/pgfplots/ztickten=,
	/pgfplots/tick scale binop/.initial=\cdot,
	/pgfplots/xtick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$},
	/pgfplots/xtick scale label code/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$},
	/pgfplots/ytick scale label code/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} 10^{#1}$},
	/pgfplots/ztick scale label code/.belongs to family=/pgfplots/tick,
	/pgfplots/tick scale label code/.style={%
		/pgfplots/xtick scale label code={#1},
		/pgfplots/ytick scale label code={#1}%
		/pgfplots/ztick scale label code={#1}%
	},%
	/pgfplots/scaled x ticks/.code={\pgfplots@scaled@ticks@setargs{x}{#1}},
	/pgfplots/scaled x ticks/false/.code=		{\def\pgfplots@scaled@ticks@x@choice{0}},
	/pgfplots/scaled x ticks/true/.code=		{\def\pgfplots@scaled@ticks@x@choice{1}},
	/pgfplots/scaled x ticks/base 10/.code=		{\def\pgfplots@scaled@ticks@x@choice{2}\def\pgfplots@scaled@ticks@x@arg{#1}},
	/pgfplots/scaled x ticks/real/.code=		{%
		\def\pgfplots@scaled@ticks@x@choice{3}\def\pgfplots@scaled@ticks@x@arg{#1}%
		\pgfkeys{/pgfplots/xtick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}},
	/pgfplots/scaled x ticks/manual/.code 2 args=		{%
		\def\pgfplots@scaled@ticks@x@choice{4}\def\pgfplots@scaled@ticks@x@arg##1{#2}%
		\pgfkeys{/pgfplots/xtick scale label code/.code={#1}}},
	/pgfplots/scaled x ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/scaled x ticks=true,
	/pgfplots/scaled y ticks/.code={\pgfplots@scaled@ticks@setargs{y}{#1}},
	/pgfplots/scaled y ticks/false/.code=		{\def\pgfplots@scaled@ticks@y@choice{0}},
	/pgfplots/scaled y ticks/true/.code=		{\def\pgfplots@scaled@ticks@y@choice{1}},
	/pgfplots/scaled y ticks/base 10/.code=		{\def\pgfplots@scaled@ticks@y@choice{2}\def\pgfplots@scaled@ticks@y@arg{#1}},
	/pgfplots/scaled y ticks/real/.code=		{%
		\def\pgfplots@scaled@ticks@y@choice{3}\def\pgfplots@scaled@ticks@y@arg{#1}%
		\pgfkeys{/pgfplots/ytick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}},
	/pgfplots/scaled y ticks/manual/.code 2 args=		{%
		\def\pgfplots@scaled@ticks@y@choice{4}\def\pgfplots@scaled@ticks@y@arg##1{#2}%
		\pgfkeys{/pgfplots/ytick scale label code/.code={#1}}},
	/pgfplots/scaled y ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/scaled y ticks=true,
	/pgfplots/scaled z ticks/.code={\pgfplots@scaled@ticks@setargs{z}{#1}},
	/pgfplots/scaled z ticks/false/.code=		{\def\pgfplots@scaled@ticks@z@choice{0}},
	/pgfplots/scaled z ticks/true/.code=		{\def\pgfplots@scaled@ticks@z@choice{1}},
	/pgfplots/scaled z ticks/base 10/.code=		{\def\pgfplots@scaled@ticks@z@choice{2}\def\pgfplots@scaled@ticks@z@arg{#1}},
	/pgfplots/scaled z ticks/real/.code=		{%
		\def\pgfplots@scaled@ticks@z@choice{3}\def\pgfplots@scaled@ticks@z@arg{#1}%
		\pgfkeys{/pgfplots/ztick scale label code/.code={$\pgfkeysvalueof{/pgfplots/tick scale binop} \pgfmathprintnumber{#1}$}}},
	/pgfplots/scaled z ticks/manual/.code 2 args=		{%
		\def\pgfplots@scaled@ticks@z@choice{4}\def\pgfplots@scaled@ticks@z@arg##1{#2}%
		\pgfkeys{/pgfplots/ztick scale label code/.code={#1}}},
	/pgfplots/scaled z ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/scaled z ticks=true,
	/pgfplots/scaled ticks/.style={%
		/pgfplots/scaled x ticks=#1,
		/pgfplots/scaled y ticks=#1,
		/pgfplots/scaled z ticks=#1
	},
	/pgfplots/scale ticks above exponent/.store in=	\pgfplots@scale@ticks@above@exponent,
	/pgfplots/scale ticks above exponent/.belongs to family=/pgfplots/tick,
	/pgfplots/scale ticks above exponent=3,
	/pgfplots/scale ticks below exponent/.store in=	\pgfplots@scale@ticks@below@exponent,
	/pgfplots/scale ticks below exponent/.belongs to family=/pgfplots/tick,
	/pgfplots/scale ticks below exponent=-1,
	/pgfplots/subtickwidth/.store in=	\pgfplots@subtickwidth,
	/pgfplots/subtickwidth/.belongs to family=/pgfplots/tick,
	/pgfplots/subtickwidth=0.1cm,
	/pgfplots/tickwidth/.store in=		\pgfplots@tickwidth,
	/pgfplots/tickwidth/.belongs to family=/pgfplots/tick,
	/pgfplots/tickwidth=0.15cm,
	/pgfplots/minor x tick num/.initial=0,
	/pgfplots/minor x tick num/.belongs to family=/pgfplots/tick,
	/pgfplots/minor y tick num/.initial=0,
	/pgfplots/minor y tick num/.belongs to family=/pgfplots/tick,
	/pgfplots/minor z tick num/.initial=0,
	/pgfplots/minor z tick num/.belongs to family=/pgfplots/tick,
	/pgfplots/minor tick num/.style={
		/pgfplots/minor x tick num=#1,
		/pgfplots/minor y tick num=#1,
		/pgfplots/minor z tick num=#1,
	},
	/pgfplots/minor tick num/.belongs to family=/pgfplots/tick,
	/pgfplots/minor tick length/.estore in=\pgfplots@subtickwidth,
	/pgfplots/minor tick length/.belongs to family=/pgfplots/tick,
	/pgfplots/major tick length/.estore in=\pgfplots@tickwidth,
	/pgfplots/major tick length/.belongs to family=/pgfplots/tick,
	/pgfplots/max space between ticks/.estore in=\axisdefaulttickwidth,
	/pgfplots/max space between ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/max space between ticks=35,% the maximum space between adjacent ticks (in pt, but don't specify the unit 'pt')
	/pgfplots/try min ticks/.estore in=			\axisdefaulttryminticks,
	/pgfplots/try min ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/try min ticks=4,
	/pgfplots/try min ticks log/.estore in=			\pgfplots@default@try@minticks@log,
	/pgfplots/try min ticks log/.belongs to family=/pgfplots/tick,
	/pgfplots/try min ticks log=3,
	/pgfplots/log basis x/.initial=,
	/pgfplots/log basis y/.initial=,
	/pgfplots/log basis z/.initial=,
	/pgfplots/log base x/.style={log basis x={#1}},%
	/pgfplots/log base y/.style={log basis y={#1}},%
	/pgfplots/log base z/.style={log basis z={#1}},%
	/pgfplots/log plot exponent style/.style={/pgf/number format/fixed,/pgf/number format/precision=2},
	/pgfplots/log plot exponent style/.belongs to family=/pgfplots/tick,
	/pgfplots/log identify minor tick positions/.is if=pgfplots@identify@log@minor@tick@pos,
	/pgfplots/log identify minor tick positions/.belongs to family=/pgfplots/tick,
	/pgfplots/log identify minor tick positions=false,
	/pgfplots/log number format code/.code={%
		\begingroup
		\pgfmathlogtologten@{#1}%
		\ifpgfplots@identify@log@minor@tick@pos
			\expandafter\pgfplots@is@log@tick@a@minor@tick@pos\pgfmathresult\relax%
		\else
			\pgfplots@log@tick@isminor@tick@posfalse
		\fi
		\ifpgfplots@log@tick@isminor@tick@pos
			\pgfmathprintnumber[sci]{\pgfmathresult}%
		\else
			\pgfkeysalso{/pgfplots/log plot exponent style,/pgfplots/log base 10 number format code=\pgfmathresult}%
		\fi
		\endgroup
	},
	/pgfplots/log number format code/.belongs to family=/pgfplots/tick,
	/pgfplots/log base 10 number format code/.code={{\pgfplots@invoke@pgfkeyscode{/pgfplots/log number format basis/.@cmd}{{10}{#1}}}},
	/pgfplots/log base 10 number format code/.belongs to family=/pgfplots/tick,
	% #1 = basis
	% #2 = exponent
	/pgfplots/log number format basis/.code 2 args={$#1^{\pgfmathprintnumber{#2}}$},
	% takes #1 = [xyz]:
	/pgfplots/log basis ticks/.style={%
		/pgfplots/every #1 tick label/.append style={%
			/pgfplots/log number format code/.code={%
				\begingroup
				\pgfkeysalso{/pgfplots/log plot exponent style}%
				\pgfplots@invoke@pgfkeyscode{/pgfplots/log number format basis/.@cmd}{{\pgfkeysvalueof{/pgfplots/log basis #1}}{####1}}%
				\endgroup
			}%
		}%
	},
% sets \pgfplots@[xy]tickposnum to
	/pgfplots/xtick pos/.is choice,
	/pgfplots/xtick pos/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick pos/left/.code	={\def\pgfplots@xtickposnum{1}},
	/pgfplots/xtick pos/left/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick pos/right/.code	={\def\pgfplots@xtickposnum{3}},
	/pgfplots/xtick pos/right/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick pos/both/.code	={\def\pgfplots@xtickposnum{0}},
	/pgfplots/xtick pos/both/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick pos=both,
	/pgfplots/ytick pos/.is choice,
	/pgfplots/ytick pos/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick pos/left/.code	={\def\pgfplots@ytickposnum{1}},
	/pgfplots/ytick pos/left/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick pos/right/.code	={\def\pgfplots@ytickposnum{3}},
	/pgfplots/ytick pos/right/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick pos/both/.code	={\def\pgfplots@ytickposnum{0}},
	/pgfplots/ytick pos/both/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick pos/top/.style={/pgfplots/ytick pos/right},
	/pgfplots/ytick pos/bottom/.style={/pgfplots/ytick pos/left},
	/pgfplots/ytick pos=both,
	/pgfplots/ztick pos/.is choice,
	/pgfplots/ztick pos/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick pos/left/.code	={\def\pgfplots@ztickposnum{1}},
	/pgfplots/ztick pos/left/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick pos/right/.code	={\def\pgfplots@ztickposnum{3}},
	/pgfplots/ztick pos/right/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick pos/both/.code	={\def\pgfplots@ztickposnum{0}},
	/pgfplots/ztick pos/both/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick pos/top/.style={/pgfplots/ztick pos/right},
	/pgfplots/ztick pos/bottom/.style={/pgfplots/ztick pos/left},
	/pgfplots/ztick pos=both,
	/pgfplots/tickpos/.style={
		/pgfplots/xtick pos={#1},
		/pgfplots/ytick pos={#1},
		/pgfplots/ztick pos={#1}
	},
	/pgfplots/tickpos/.belongs to family=/pgfplots/tick,
	/pgfplots/tick pos/.style={/pgfplots/tickpos={#1}},
% sets the tick LABEL position, \pgfplots@[xy]ticklabel@pos
% to one of
% lower (alias left alias bottom)    : l
% upper (alias right alias top)      : u
% default: uses one matches 'tick pos'
	/pgfplots/xticklabel pos/.code={\pgfplots@setkey@ticklabelpos{x}{#1}},
	/pgfplots/xticklabel pos/.belongs to family=/pgfplots/tick,
	/pgfplots/xticklabel pos=default,
	/pgfplots/yticklabel pos/.code={\pgfplots@setkey@ticklabelpos{y}{#1}},
	/pgfplots/yticklabel pos/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabel pos=default,
	/pgfplots/zticklabel pos/.code={\pgfplots@setkey@ticklabelpos{z}{#1}},
	/pgfplots/zticklabel pos/.belongs to family=/pgfplots/tick,
	/pgfplots/zticklabel pos=default,
	/pgfplots/ticklabelpos/.style={/pgfplots/ticklabel pos={#1}},
	/pgfplots/ticklabel pos/.style={
		/pgfplots/xticklabel pos={#1},
		/pgfplots/yticklabel pos={#1},
		/pgfplots/zticklabel pos={#1},
	},
	% This feature is more or less deprecated.
	% The choice 'auto' should always use 'near ticklabel'.
	%
	% Choices are 
	% 	'auto' (value 0),
	% 	'near ticklabel' (value 1), 
	% 	'tikz' (value 2)
	% with values stored in \pgfplots@ticklabel@anchor@[xyz] 
	/pgfplots/xticklabel anchor/.code={\pgfplots@setticklabel@anchor@for x{#1}},
	/pgfplots/xticklabel anchor/.belongs to family=/pgfplots/tick,
	/pgfplots/yticklabel anchor/.code={\pgfplots@setticklabel@anchor@for y{#1}},
	/pgfplots/yticklabel anchor/.belongs to family=/pgfplots/tick,
	/pgfplots/zticklabel anchor/.code={\pgfplots@setticklabel@anchor@for z{#1}},
	/pgfplots/zticklabel anchor/.belongs to family=/pgfplots/tick,
	/pgfplots/ticklabel anchor/.style={
		/pgfplots/xticklabel anchor={#1},
		/pgfplots/yticklabel anchor={#1},
		/pgfplots/zticklabel anchor={#1}
	},
	/pgfplots/ticklabel anchor=auto,
	/pgfplots/xticklabel shift/.initial=,
	/pgfplots/yticklabel shift/.initial=,
	/pgfplots/zticklabel shift/.initial=,
	/pgfplots/ticklabel shift/.style={
		/pgfplots/xticklabel shift={#1},
		/pgfplots/yticklabel shift={#1},
		/pgfplots/zticklabel shift={#1}
	},%
% sets \pgfplots@{x,y}tickalignnum to
% inside=0
% outside=1
% center=2
	/pgfplots/xtick align/.is choice,
	/pgfplots/xtick align/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick align/inside/.code	={\def\pgfplots@xtickalignnum{0}},
	/pgfplots/xtick align/inside/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick align/outside/.code	={\def\pgfplots@xtickalignnum{1}},
	/pgfplots/xtick align/outside/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick align/center/.code	={\def\pgfplots@xtickalignnum{2}},
	/pgfplots/xtick align/center/.belongs to family=/pgfplots/tick,
	/pgfplots/xtick align=inside,
	/pgfplots/ytick align/.is choice,
	/pgfplots/ytick align/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick align/inside/.code	={\def\pgfplots@ytickalignnum{0}},
	/pgfplots/ytick align/inside/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick align/outside/.code	={\def\pgfplots@ytickalignnum{1}},
	/pgfplots/ytick align/outside/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick align/center/.code	={\def\pgfplots@ytickalignnum{2}},
	/pgfplots/ytick align/center/.belongs to family=/pgfplots/tick,
	/pgfplots/ytick align=inside,
	/pgfplots/ztick align/.is choice,
	/pgfplots/ztick align/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick align/inside/.code	={\def\pgfplots@ztickalignnum{0}},
	/pgfplots/ztick align/inside/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick align/outside/.code	={\def\pgfplots@ztickalignnum{1}},
	/pgfplots/ztick align/outside/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick align/center/.code	={\def\pgfplots@ztickalignnum{2}},
	/pgfplots/ztick align/center/.belongs to family=/pgfplots/tick,
	/pgfplots/ztick align=inside,
	/pgfplots/tick align/.belongs to family=/pgfplots/tick,
	/pgfplots/tick align/.style={%
		/pgfplots/xtick align=#1,
		/pgfplots/ytick align=#1,
		/pgfplots/ztick align=#1,
	},%
% 'axis' options:
	/pgfplots/anchor/.belongs to family=/pgfplots,
	/pgfplots/anchor/.store in=			\pgfplots@anchorname,
	/pgfplots/anchor=south west,
% tick options:
	/pgfplots/ticks/.is choice,
	/pgfplots/ticks/.belongs to family=/pgfplots/tick,
	/pgfplots/ticks/none/.belongs to family=/pgfplots/tick,
	/pgfplots/ticks/none/.code={%
		\pgfplots@xminorticksfalse
		\pgfplots@yminorticksfalse
		\pgfplots@zminorticksfalse
		\pgfplots@xmajorticksfalse
		\pgfplots@ymajorticksfalse
		\pgfplots@zmajorticksfalse
	},
	/pgfplots/ticks/major/.belongs to family=/pgfplots/tick,
	/pgfplots/ticks/major/.code={%
		\pgfplots@xminorticksfalse
		\pgfplots@yminorticksfalse
		\pgfplots@zminorticksfalse
		\pgfplots@xmajortickstrue
		\pgfplots@ymajortickstrue
		\pgfplots@zmajortickstrue
	},
	/pgfplots/ticks/minor/.belongs to family=/pgfplots/tick,
	/pgfplots/ticks/minor/.code={%
		\pgfplots@xminortickstrue
		\pgfplots@yminortickstrue
		\pgfplots@zminortickstrue
		\pgfplots@xmajorticksfalse
		\pgfplots@ymajorticksfalse
		\pgfplots@zmajorticksfalse
	},
	/pgfplots/ticks/both/.belongs to family=/pgfplots/tick,
	/pgfplots/ticks/both/.code={%
		\pgfplots@xminortickstrue
		\pgfplots@yminortickstrue
		\pgfplots@zminortickstrue
		\pgfplots@xmajortickstrue
		\pgfplots@ymajortickstrue
		\pgfplots@zmajortickstrue
	},
	/pgfplots/ticks=both,
	/pgfplots/grid/.is choice,
	/pgfplots/grid/.belongs to family=/pgfplots/tick,
	/pgfplots/grid/none/.belongs to family=/pgfplots/tick,
	/pgfplots/grid/none/.code={%
		\pgfplots@xminorgridsfalse
		\pgfplots@yminorgridsfalse
		\pgfplots@zminorgridsfalse
		\pgfplots@xmajorgridsfalse
		\pgfplots@ymajorgridsfalse
		\pgfplots@zmajorgridsfalse
	},
	/pgfplots/grid/major/.belongs to family=/pgfplots/tick,
	/pgfplots/grid/major/.code={%
		\pgfplots@xminorgridsfalse
		\pgfplots@yminorgridsfalse
		\pgfplots@zminorgridsfalse
		\pgfplots@xmajorgridstrue
		\pgfplots@ymajorgridstrue
		\pgfplots@zmajorgridstrue
	},
	/pgfplots/grid/minor/.belongs to family=/pgfplots/tick,
	/pgfplots/grid/minor/.code={%
		\pgfplots@xminorgridstrue
		\pgfplots@yminorgridstrue
		\pgfplots@zminorgridstrue
		\pgfplots@xmajorgridsfalse
		\pgfplots@ymajorgridsfalse
		\pgfplots@zmajorgridsfalse
	},
	/pgfplots/grid/both/.belongs to family=/pgfplots/tick,
	/pgfplots/grid/both/.code={%
		\pgfplots@xminorgridstrue
		\pgfplots@yminorgridstrue
		\pgfplots@zminorgridstrue
		\pgfplots@xmajorgridstrue
		\pgfplots@ymajorgridstrue
		\pgfplots@zmajorgridstrue
	},
	/pgfplots/grid=none,
	/pgfplots/grid/.default=major,
	/pgfplots/xminorticks/.is if=pgfplots@xminorticks,
	/pgfplots/xminorticks/.default=true,
	/pgfplots/xminorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/xmajorticks/.is if=pgfplots@xmajorticks,
	/pgfplots/xmajorticks/.default=true,
	/pgfplots/xmajorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/yminorticks/.is if=pgfplots@yminorticks,
	/pgfplots/yminorticks/.default=true,
	/pgfplots/yminorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/ymajorticks/.is if=pgfplots@ymajorticks,
	/pgfplots/ymajorticks/.default=true,
	/pgfplots/ymajorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/zminorticks/.is if=pgfplots@zminorticks,
	/pgfplots/zminorticks/.default=true,
	/pgfplots/zminorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/zmajorticks/.is if=pgfplots@zmajorticks,
	/pgfplots/zmajorticks/.default=true,
	/pgfplots/zmajorticks/.belongs to family=/pgfplots/tick,
	/pgfplots/xminorgrids/.is if=pgfplots@xminorgrids,
	/pgfplots/xminorgrids/.default=true,
	/pgfplots/xminorgrids/.belongs to family=/pgfplots/tick,
	/pgfplots/xmajorgrids/.is if=pgfplots@xmajorgrids,
	/pgfplots/xmajorgrids/.default=true,
	/pgfplots/xmajorgrids/.belongs to family=/pgfplots/tick,
	/pgfplots/yminorgrids/.is if=pgfplots@yminorgrids,
	/pgfplots/yminorgrids/.default=true,
	/pgfplots/yminorgrids/.belongs to family=/pgfplots/tick,
	/pgfplots/ymajorgrids/.is if=pgfplots@ymajorgrids,
	/pgfplots/ymajorgrids/.default=true,
	/pgfplots/ymajorgrids/.belongs to family=/pgfplots/tick,
	/pgfplots/zminorgrids/.is if=pgfplots@zminorgrids,
	/pgfplots/zminorgrids/.default=true,
	/pgfplots/zminorgrids/.belongs to family=/pgfplots/tick,
	/pgfplots/zmajorgrids/.is if=pgfplots@zmajorgrids,
	/pgfplots/zmajorgrids/.default=true,
	/pgfplots/zmajorgrids/.belongs to family=/pgfplots/tick,
% legend options:
	/pgfplots/legend entries/.initial={},
	/pgfplots/legend entries/.belongs to family=/pgfplots/legend,
	/pgfplots/legend to label/.style={/pgfplots/legend to name={#1}},
	/pgfplots/legend to name/.initial=,%
	/pgfplots/legend pos/.is choice,
	/pgfplots/legend pos/south west/.style={/pgfplots/legend style={at={(0.03,0.03)},anchor=south west}},
	/pgfplots/legend pos/south east/.style={/pgfplots/legend style={at={(0.97,0.03)},anchor=south east}},
	/pgfplots/legend pos/north west/.style={/pgfplots/legend style={at={(0.03,0.97)},anchor=north west}},
	/pgfplots/legend pos/north east/.style={/pgfplots/legend style={at={(0.97,0.97)},anchor=north east}},
	/pgfplots/legend pos/outer north east/.style={/pgfplots/legend style={at={(1.03,1)},anchor=north west}},
	/pgfplots/legend cell align/.is choice,
	/pgfplots/legend cell align/left/.style=	{/pgfplots/legend style={cells={anchor=west}}},
	/pgfplots/legend cell align/right/.style=	{/pgfplots/legend style={cells={anchor=east}}},
	/pgfplots/legend cell align/center/.style=	{/pgfplots/legend style={cells={anchor=center}}},
	/pgfplots/legend columns/.store in=\pgfplots@legend@columns,
	/pgfplots/legend columns/.belongs to family=/pgfplots/legend,
	/pgfplots/legend columns=1,
	/pgfplots/legend plot pos/.is choice,
	/pgfplots/legend plot pos/.belongs to family=/pgfplots/legend,
	/pgfplots/legend plot pos/left/.code=	{\def\pgfplots@legend@plot@pos{0}},
	/pgfplots/legend plot pos/left/.belongs to family=/pgfplots/legend,
	/pgfplots/legend plot pos/right/.code=	{\def\pgfplots@legend@plot@pos{1}},
	/pgfplots/legend plot pos/right/.belongs to family=/pgfplots/legend,
	/pgfplots/legend plot pos/none/.code=	{\def\pgfplots@legend@plot@pos{2}},
	/pgfplots/legend plot pos/none/.belongs to family=/pgfplots/legend,
	/pgfplots/legend plot pos=left,
	/pgfplots/every legend image post/.code={},%
	/pgfplots/legend image post style/.style={/pgfplots/every legend image post/.append style={#1}},
	/pgfplots/empty legend/.style={/pgfplots/legend image code/.code=},
	/pgfplots/line legend/.style={%
		/pgfplots/legend image code/.code={%
			\draw[mark repeat=2,mark phase=2,##1] 
				plot coordinates {
					(0cm,0cm) 
					(0.3cm,0cm)
					(0.6cm,0cm)%
				};%
		}%
	},	
	/pgfplots/line legend,
	/pgfplots/legend image code/.belongs to family=/pgfplots/legend,
	/pgfplots/reverse legend/.is if=pgfplots@reverse@legend,
	/pgfplots/reverse legend/.default=true,
	/pgfplots/transpose legend/.is if=pgfplots@transpose@legend,
	/pgfplots/transpose legend/.default=true,
	/pgfplots/legend transposed/.style={transpose legend=#1},
	/pgfplots/legend reversed/.style={reverse legend=#1},
% axis description options:
	/pgfplots/title/.initial=,
	/pgfplots/xlabel/.initial=,
	/pgfplots/ylabel/.initial=,
	/pgfplots/zlabel/.initial=,
	/pgfplots/xlabel shift/.initial=0pt,
	/pgfplots/ylabel shift/.initial=0pt,
	/pgfplots/zlabel shift/.initial=0pt,
	/pgfplots/label shift/.style={%
		/pgfplots/xlabel shift={#1},
		/pgfplots/ylabel shift={#1},
		/pgfplots/zlabel shift={#1},
	},%
	/pgfplots/before end axis/.code=,
	/pgfplots/after end axis/.code=,
	/pgfplots/extra description/.code=,
% axis options:
	/pgfplots/at/.code={%
		\pgfplots@assert@tikzinternal@exists{tikz@scan@one@point}%
		\tikz@scan@one@point\pgfplots@set@at#1},
	/pgfplots/at/.belongs to family=/pgfplots,
	/pgfplots/trim axis left/.code={%
		\pgfutil@ifundefined{pgfsettrimleft}{%
			\pgfplots@error{Sorry, the 'trim axis left' requires a more recent PGF version. At the time of this writing, only the experimental PGF version available from texexample.net supports it.}%
		}{%
			\pgfkeysalso{/tikz/trim left=(current axis.south west)}%
		}%
	},%
	/tikz/trim axis left/.style={/pgfplots/trim axis left},
	/pgfplots/trim axis right/.code={%
		\pgfutil@ifundefined{pgfsettrimleft}{%
			\pgfplots@error{Sorry, the 'trim axis right' requires a more recent PGF version. At the time of this writing, only the experimental PGF version available from texexample.net supports it.}%
		}{%
			\pgfkeysalso{/tikz/trim right=(current axis.south east)}%
		}%
	},%
	/tikz/trim axis right/.style={/pgfplots/trim axis right},
	/pgfplots/clip limits/.is if=pgfplots@clip@limits,
	/pgfplots/clip limits/.default=true,
	/pgfplots/clip limits=true,
	/pgfplots/clip limits/.belongs to family=/pgfplots,
	/pgfplots/clip/.is if=pgfplots@clip,
	% will be used if it exists:
	%/pgfplots/axis background/.style={},
	/pgfplots/axis equal/.is if=pgfplots@axis@equal,
	/pgfplots/axis equal/.default=true,
	/pgfplots/axis equal image/.is if=pgfplots@axis@equal@image,
	/pgfplots/axis equal image/.default=true,
	/pgfplots/xmin/.initial=,
	/pgfplots/xmax/.initial=,
	/pgfplots/ymin/.initial=,
	/pgfplots/ymax/.initial=,
	/pgfplots/zmin/.initial=,
	/pgfplots/zmax/.initial=,
	/pgfplots/xtickmin/.initial=,
	/pgfplots/xtickmax/.initial=,
	/pgfplots/ytickmin/.initial=,
	/pgfplots/ytickmax/.initial=,
	/pgfplots/ztickmin/.initial=,
	/pgfplots/ztickmax/.initial=,
	/pgfplots/stack plots/.is choice,
	/pgfplots/stack plots/.belongs to family=/pgfplots,
	/pgfplots/stack plots/x/.code={\def\pgfplots@stacked@dir{x}\pgfplots@stackedmodetrue},
	/pgfplots/stack plots/x/.belongs to family=/pgfplots,
	/pgfplots/stack plots/y/.code={\def\pgfplots@stacked@dir{y}\pgfplots@stackedmodetrue},
	/pgfplots/stack plots/y/.belongs to family=/pgfplots,
	/pgfplots/stack plots/z/.code={\def\pgfplots@stacked@dir{z}\pgfplots@stackedmodetrue},
	/pgfplots/stack plots/z/.belongs to family=/pgfplots,
	/pgfplots/stack plots/false/.code={\pgfplots@stackedmodefalse},
	/pgfplots/stack plots/false/.belongs to family=/pgfplots,
	/pgfplots/stack plots=false,
	/pgfplots/reverse stacked plots/.is if=pgfplots@stacked@reverse,
	/pgfplots/reverse stacked plots/.belongs to family=/pgfplots,
	/pgfplots/reverse stacked plots/.default=true,
	/pgfplots/reverse stacked plots=true,
	/pgfplots/stack dir/.is choice,
	/pgfplots/stack dir/.belongs to family=/pgfplots,
	/pgfplots/stack dir/plus/.code={\pgfplots@stacked@plustrue},
	/pgfplots/stack dir/plus/.belongs to family=/pgfplots,
	/pgfplots/stack dir/minus/.code={\pgfplots@stacked@plusfalse},
	/pgfplots/stack dir/minus/.belongs to family=/pgfplots,
	/pgfplots/stack dir=plus,
	/pgfplots/filter discard warning/.is if=pgfplots@warn@for@filter@discards,
	/pgfplots/filter discard warning=true,
	/pgfplots/x filter/.code={},
	/pgfplots/x filter/.belongs to family=/pgfplots,
	/pgfplots/y filter/.code={},
	/pgfplots/y filter/.belongs to family=/pgfplots,
	/pgfplots/z filter/.code={},
	/pgfplots/z filter/.belongs to family=/pgfplots,
	/pgfplots/filter point/.code=,
	/pgfplots/restrict x to domain/.style={/pgfplots/@restrict to domain={x}{}{#1}{0}},%
	/pgfplots/restrict y to domain/.style={/pgfplots/@restrict to domain={y}{}{#1}{0}},%
	/pgfplots/restrict z to domain/.style={/pgfplots/@restrict to domain={z}{}{#1}{0}},%
	/pgfplots/restrict expr to domain/.style 2 args={/pgfplots/@restrict to domain={x}{#1}{#2}{0}},%
	/pgfplots/restrict x to domain*/.style={/pgfplots/@restrict to domain={x}{}{#1}{1}},%
	/pgfplots/restrict y to domain*/.style={/pgfplots/@restrict to domain={y}{}{#1}{1}},%
	/pgfplots/restrict z to domain*/.style={/pgfplots/@restrict to domain={z}{}{#1}{1}},%
	/pgfplots/restrict expr to domain*/.style 2 args={/pgfplots/@restrict to domain={x}{#1}{#2}{1}},%
	% '#1': the filter to install
	% '#2': a mathematical expression (or empty)
	% '#3': the interval. must be numeric currently. 
	% '#4': bAssignLimits=0|1. if #4=1, any coordinate outside of the
	% allowed domain will take the domain boundary as value. If #4=0,
	% any coordinate outside of the allowed domain will get 'inf' or
	% '-inf'.
	/pgfplots/@restrict to domain/.code args={#1#2#3#4}{%
		\if0#4%
			\pgfkeysalso{/pgfplots/unbounded coords=jump}%
		\fi
		% when invoked, ##1 and ##2 will be floats:
		\def\pgfplots@loc@TMPb##1:##2\relax{%
			\pgfkeysalso{%
				/pgfplots/#1 filter/.append code={%
					\let\pgfplots@restrict@to@domain@orig=\pgfmathresult
					\def\pgfplots@restrict@to@domain@tmp{#2}%
					\ifx\pgfplots@restrict@to@domain@tmp\pgfutil@empty
						% we don't have an expression.
						\pgfmathfloatparsenumber{\pgfmathresult}%
					\else
						% evaluate the expression!
						\pgfmathparse{#2}%
					\fi
					\let\pgfplots@restrict@to@domain@tmp=\pgfmathresult
					\pgfmathfloatlessthan@{\pgfplots@restrict@to@domain@tmp}{##1}% ##1 is the lower argument
					\ifpgfmathfloatcomparison
						\edef\pgfmathresult{\if0#4inf\else ##1\fi}%
					\else
						\pgfmathfloatgreaterthan@{\pgfplots@restrict@to@domain@tmp}{##2}%
						\ifpgfmathfloatcomparison
							\edef\pgfmathresult{\if0#4-inf\else ##2\fi}%
						\else
							\let\pgfmathresult=\pgfplots@restrict@to@domain@orig
						\fi
					\fi
				}%
			}%
		}%
		% when invoked, ##1 and ##2 will be the user-supplied args.
		\def\pgfplots@loc@TMPc##1:##2\relax{%
			\pgfmathfloatparsenumber{##1}%
			\let\pgfplots@rangea=\pgfmathresult
			\pgfmathfloatparsenumber{##2}%
			\edef\pgfplots@loc@TMPc{\pgfplots@rangea:\pgfmathresult}%
			\expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPc\relax
		}%
		\edef\pgfplots@loc@TMPa{#3}%
		\expandafter\pgfplots@loc@TMPc\pgfplots@loc@TMPa\relax
	},%
	% -> keeps only the nth point, all other ones will get ''. 
	/pgfplots/each nth point/.style={%
		/pgfplots/x filter/.append code={%
			\ifnum\coordindex=0
				\def\c@pgfplots@eachnthpoint@xfilter{0}%
				\edef\c@pgfplots@eachnthpoint@xfilter@cmp{#1}%
			\else
				\pgfplotsutil@advancestringcounter\c@pgfplots@eachnthpoint@xfilter
				\ifx\c@pgfplots@eachnthpoint@xfilter@cmp\c@pgfplots@eachnthpoint@xfilter
					\def\c@pgfplots@eachnthpoint@xfilter{0}%
				\else
					\let\pgfmathresult\pgfutil@empty
				\fi
			\fi
		}%
	},
	/pgfplots/skip coords between index/.style 2 args={%
		/pgfplots/x filter/.append code={%
			\ifnum\coordindex<#1\relax
			\else
				\ifnum\coordindex<#2\relax
					\let\pgfmathresult=\pgfutil@empty
				\fi
			\fi}
	},
	/pgfplots/translate gnuplot/.is if=pgfplots@translategnuplot,
	/pgfplots/gnuplot writes logscale/.is choice,
	/pgfplots/gnuplot writes logscale/true/.code={\gdef\pgfplots@gnuplot@logscale@writes@log{1}},%
	/pgfplots/gnuplot writes logscale/false/.code={\gdef\pgfplots@gnuplot@logscale@writes@log{0}},%
	/pgfplots/parametric/var 2d/.initial={\u,\v},
	/pgfplots/parametric/var 1d/.initial=\t,
	/pgfplots/xfilter/.initial=,% DEPRECATED
	/pgfplots/yfilter/.initial=,% DEPRECATED
	/pgfplots/zfilter/.initial=,% DEPRECATED
	% interpretation: 
	% if 'samples at'==empty && 'domain' == empty 
	% 	use tikz option	processing!
	% else if 'samples at' == empty
	% 	use 'domain'
	% else
	% 	use 'samples at'
	/pgfplots/domain/.initial=,% empty -> use value of /tikz/domain! see \pgfplots@validate@plot@domain@arguments
	/pgfplots/y domain/.initial=,% means: use the same as 'domain'
	/pgfplots/domain y/.style={/pgfplots/y domain={#1}},
	/pgfplots/samples at/.initial=,% empty -> use value of /tikz/samples at!
	/pgfplots/samples/.initial=,% empty -> use /tikz/samples!
	/pgfplots/samples y/.initial=,% empty -> use the same as 'samples'. For use in mesh plots.
	/pgfplots/variable/.code={\pgfkeysalso{/tikz/variable={#1}}},
	/pgfplots/variable y/.initial=\y,%
	% and provide aliases in the '/pgfplots/' tree to avoid 
	% search path problems just for the following options:
	/pgfplots/name/.code={\pgfkeysalso{/tikz/name={#1}}},
	/pgfplots/overlay/.code={\pgfkeysalso{/tikz/overlay={#1}}},
	/pgfplots/alias/.code={\pgfkeysalso{/tikz/alias={#1}}},
	/pgfplots/id/.code={\pgfkeysalso{/tikz/id={#1}}},
	/pgfplots/prefix/.code={\pgfkeysalso{/tikz/prefix={#1}}},
	/pgfplots/raw gnuplot/.code={\pgfkeysalso{/tikz/raw gnuplot={#1}}},
	/pgfplots/parametric/.code={\pgfkeysalso{/tikz/parametric={#1}}},%
	%
	/pgfplots/width/.initial=,%
	/pgfplots/width/.belongs to family=/pgfplots,
	/pgfplots/height/.initial=,%
	/pgfplots/height/.belongs to family=/pgfplots,
	/pgfplots/execute at begin plot/.initial=,
	/pgfplots/execute at begin plot@@/.initial=,% an internal variant
	/pgfplots/execute at end plot/.initial=,
	/pgfplots/execute at end plot@@/.initial=,% an internal variant
	/pgfplots/enlarge x limits/.initial=auto,
	/pgfplots/enlarge x limits/.default=true,
	/pgfplots/enlarge y limits/.initial=auto,
	/pgfplots/enlarge y limits/.default=true,
	/pgfplots/enlarge z limits/.initial=auto,
	/pgfplots/enlarge z limits/.default=true,
	/pgfplots/enlargelimits/.style={%
		/pgfplots/enlarge x limits=#1,%
		/pgfplots/enlarge y limits=#1,%
		/pgfplots/enlarge z limits=#1,%
	},%
	/pgfplots/enlargelimits/.default=true,
	/pgfplots/update limits/.is if=pgfplots@bb@isactive,
	/pgfplots/x/.initial=,% is implicitly set by 'width' and/or '\axisdefaultwidth'
	/pgfplots/x/.belongs to family=/pgfplots,
	/pgfplots/y/.initial=,% is implicitly set by 'width' and/or '\axisdefaultwidth'
	/pgfplots/y/.belongs to family=/pgfplots,
	/pgfplots/z/.initial=,
	/pgfplots/z/.belongs to family=/pgfplots,
	/pgfplots/x dir/.code={\pgfplots@setkey@axisdir@for x{#1}},%
	/pgfplots/y dir/.code={\pgfplots@setkey@axisdir@for y{#1}},%
	/pgfplots/z dir/.code={\pgfplots@setkey@axisdir@for z{#1}},%
	/pgfplots/x dir=normal,%
	/pgfplots/y dir=normal,%
	/pgfplots/z dir=normal,%
	/pgfplots/allow reversal of rel axis cs/.is if=pgfplots@allow@reversal@of@rel@axis@cs,%
	/pgfplots/allow reversal of rel axis cs/.default=true,%
	/pgfplots/allow reversal of rel axis cs=true,%
	/pgfplots/plot box ratio/.initial={1}{1}{1},%
	/pgfplots/view/az/.initial=25,%
	/pgfplots/view/h/.code={\pgfkeyssetvalue{/pgfplots/view/az}{#1}},%
	/pgfplots/view/el/.initial=30,%
	/pgfplots/view/v/.code={\pgfkeyssetvalue{/pgfplots/view/el}{#1}},%
	/pgfplots/view/.style 2 args={%
		/pgfplots/view/az={#1},%
		/pgfplots/view/el={#2}%
	},%
	/pgfplots/cycle list/.code={%
		\pgfplots@assign@list\autoplotspeclist{#1}%
		\expandafter\let\csname pgfp@cyclist@auto@\endcsname=\autoplotspeclist
		\pgfkeyssetvalue{/pgfplots/cycle multi list/@dim}{0}% de-activate.
	},
	/pgfplots/cycle list/.belongs to family=/pgfplots,
	/pgfplots/cycle list name/.code={%
		\pgfplotsifcyclelistexists{#1}{%
			\expandafter\let\expandafter\autoplotspeclist\csname pgfp@cyclist@\string#1@\endcsname
			\expandafter\let\csname pgfp@cyclist@auto@\endcsname=\autoplotspeclist
			\pgfkeyssetvalue{/pgfplots/cycle multi list/@dim}{0}% de-activate.
		}{%
			\pgfplots@error{Sorry, there is no such cycle list named \string#1. Maybe you misspelled it?}%
		}%
	},
	/pgfplots/cycle list name/.belongs to family=/pgfplots,
	/pgfplots/cycle list name=color,
	/pgfplots/cycle list shift/.initial=,
	% accepts arguments of the form
	% <first list spec>\nextlist <second list spec>\nextlist ....
	% where each list spec is EITHER a cycle list name OR a cycle list
	% argument.
	/pgfplots/cycle multi list/.code={\pgfplots@cycle@multi@list{#1}},
	% #1: list index
	% #2: maximum number of elements to use
	/pgfplots/cycle multi list/partial sublist/.code 2 args={%
		\ifnum#1<\pgfkeysvalueof{/pgfplots/cycle multi list/@dim}
			\ifnum#2<\pgfkeysvalueof{/pgfplots/cycle multi list/@totalN#1}
				\pgfkeyssetvalue{/pgfplots/cycle multi list/@N#1}{#2}%
			\fi
		\else
			\pgfplots@error{Sorry, the first argument of `cycle multi list/partial sublist=<list index><num elems>' is no valid list index (should be less than \pgfkeysvalueof{/pgfplots/cycle multi list/@dim}).}%
		\fi
	},%
	/pgfplots/cycle multi list/@dim/.initial=0,
	%/pgfplots/cycle multi list/@list0/.style={},
	%/pgfplots/cycle multi list/@N0/.initial=0,%
	%/pgfplots/cycle multi list/@totalN0/.initial=0,%
	/pgfplots/legend style/.belongs to family=/pgfplots/style commands,
	/pgfplots/legend style/.code={%
		\pgfkeysalso{/pgfplots/every axis legend/.append style={#1}}%
	},
	/pgfplots/every forget plot/.code={},%
	/pgfplots/forget plot style/.style={/pgfplots/every forget plot/.append style={#1}},
	/pgfplots/label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/label style/.style={%
		/pgfplots/every axis x label/.append style={#1},%
		/pgfplots/every axis y label/.append style={#1},%
		/pgfplots/every axis z label/.append style={#1}%
	},%
	/pgfplots/x label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/x label style/.code={%
		\pgfkeysalso{/pgfplots/every axis x label/.append style={#1}}%
	},
	/pgfplots/y label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y label style/.code={%
		\pgfkeysalso{/pgfplots/every axis y label/.append style={#1}}%
	},
	/pgfplots/z label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/z label style/.code={%
		\pgfkeysalso{/pgfplots/every axis z label/.append style={#1}}%
	},
	/pgfplots/title style/.belongs to family=/pgfplots/style commands,
	/pgfplots/title style/.code={%
		\pgfkeysalso{/pgfplots/every axis title/.append style={#1}}%
	},
	/pgfplots/tick label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/tick label style/.code={%
		\pgfkeysalso{/pgfplots/every tick label/.append style={#1}}%
	},
	/pgfplots/x tick label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/x tick label style/.code={%
		\pgfkeysalso{/pgfplots/every x tick label/.append style={#1}}%
	},
	/pgfplots/y tick label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y tick label style/.code={%
		\pgfkeysalso{/pgfplots/every y tick label/.append style={#1}}%
	},
	/pgfplots/z tick label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/z tick label style/.code={%
		\pgfkeysalso{/pgfplots/every z tick label/.append style={#1}}%
	},
	/pgfplots/x tick scale label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/x tick scale label style/.code={%
		\pgfkeysalso{/pgfplots/every x tick scale label/.append style={#1}}%
	},
	/pgfplots/y tick scale label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y tick scale label style/.code={%
		\pgfkeysalso{/pgfplots/every y tick scale label/.append style={#1}}%
	},
	/pgfplots/z tick scale label style/.belongs to family=/pgfplots/style commands,
	/pgfplots/z tick scale label style/.code={%
		\pgfkeysalso{/pgfplots/every z tick scale label/.append style={#1}}%
	},
	/pgfplots/tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/tick style/.code={%
		\pgfkeysalso{/pgfplots/every tick/.append style={#1}}%
	},
	/pgfplots/minor tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor tick style/.code={%
		\pgfkeysalso{/pgfplots/every minor tick/.append style={#1}}%
	},
	/pgfplots/major tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major tick style/.code={%
		\pgfkeysalso{/pgfplots/every major tick/.append style={#1}}%
	},
	/pgfplots/x tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/x tick style/.code={%
		\pgfkeysalso{/pgfplots/every x tick/.append style={#1}}%
	},
	/pgfplots/minor x tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor x tick style/.code={%
		\pgfkeysalso{/pgfplots/every minor x tick/.append style={#1}}%
	},
	/pgfplots/major x tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major x tick style/.code={%
		\pgfkeysalso{/pgfplots/every major x tick/.append style={#1}}%
	},
	/pgfplots/y tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y tick style/.code={%
		\pgfkeysalso{/pgfplots/every y tick/.append style={#1}}%
	},
	/pgfplots/minor y tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor y tick style/.code={%
		\pgfkeysalso{/pgfplots/every minor y tick/.append style={#1}}%
	},
	/pgfplots/major y tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major y tick style/.code={%
		\pgfkeysalso{/pgfplots/every major y tick/.append style={#1}}%
	},
	/pgfplots/z tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/z tick style/.code={%
		\pgfkeysalso{/pgfplots/every z tick/.append style={#1}}%
	},
	/pgfplots/minor z tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor z tick style/.code={%
		\pgfkeysalso{/pgfplots/every minor z tick/.append style={#1}}%
	},
	/pgfplots/major z tick style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major z tick style/.code={%
		\pgfkeysalso{/pgfplots/every major z tick/.append style={#1}}%
	},
	/pgfplots/grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/grid style/.code={%
		\pgfkeysalso{/pgfplots/every axis grid/.append style={#1}}%
	},
	/pgfplots/minor grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor grid style/.code={%
		\pgfkeysalso{/pgfplots/every minor grid/.append style={#1}}%
	},
	/pgfplots/major grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major grid style/.code={%
		\pgfkeysalso{/pgfplots/every major grid/.append style={#1}}%
	},
	/pgfplots/x grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/x grid style/.code={%
		\pgfkeysalso{/pgfplots/every axis x grid/.append style={#1}}%
	},
	/pgfplots/minor x grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor x grid style/.code={%
		\pgfkeysalso{/pgfplots/every minor x grid/.append style={#1}}%
	},
	/pgfplots/major x grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major x grid style/.code={%
		\pgfkeysalso{/pgfplots/every major x grid/.append style={#1}}%
	},
	/pgfplots/y grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y grid style/.code={%
		\pgfkeysalso{/pgfplots/every axis y grid/.append style={#1}}%
	},
	/pgfplots/minor y grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor y grid style/.code={%
		\pgfkeysalso{/pgfplots/every minor y grid/.append style={#1}}%
	},
	/pgfplots/major y grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major y grid style/.code={%
		\pgfkeysalso{/pgfplots/every major y grid/.append style={#1}}%
	},
	/pgfplots/y grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/y grid style/.code={%
		\pgfkeysalso{/pgfplots/every axis z grid/.append style={#1}}%
	},
	/pgfplots/minor z grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/minor z grid style/.code={%
		\pgfkeysalso{/pgfplots/every minor z grid/.append style={#1}}%
	},
	/pgfplots/major z grid style/.belongs to family=/pgfplots/style commands,
	/pgfplots/major z grid style/.code={%
		\pgfkeysalso{/pgfplots/every major z grid/.append style={#1}}%
	},
	/pgfplots/disablelogfilter x/.is if=pgfplots@disablelogfilter@x,
	/pgfplots/disablelogfilter x/.default=true,
	/pgfplots/disablelogfilter y/.is if=pgfplots@disablelogfilter@y,
	/pgfplots/disablelogfilter y/.default=true,
	/pgfplots/disablelogfilter z/.is if=pgfplots@disablelogfilter@z,
	/pgfplots/disablelogfilter z/.default=true,
	/pgfplots/disablelogfilter/.style={	
		/pgfplots/disablelogfilter x=#1,
		/pgfplots/disablelogfilter y=#1,
		/pgfplots/disablelogfilter z=#1,
	},
	/pgfplots/disabledatascaling/.is if=pgfplots@disabledatascaling,
	/pgfplots/disabledatascaling/.default=true,
	/pgfplots/disabledatascaling/.belongs to family=/pgfplots,
	/pgfplots/disabledatascaling=false,
	/pgfplots/hide x axis/.is if=pgfplots@hide@x,
	/pgfplots/hide x axis/.default=true,
	/pgfplots/hide x axis=false,
	/pgfplots/hide y axis/.is if=pgfplots@hide@y,
	/pgfplots/hide y axis/.default=true,
	/pgfplots/hide y axis=false,
	/pgfplots/hide z axis/.is if=pgfplots@hide@z,
	/pgfplots/hide z axis/.default=true,
	/pgfplots/hide z axis=false,
	/pgfplots/hide axis/.style={%
		/pgfplots/hide x axis=#1,
		/pgfplots/hide y axis=#1,
		/pgfplots/hide z axis=#1,
	},
	/pgfplots/hide axis/.default=true,
	/pgfplots/every non boxed x axis/.style={%
		xtick align=center,
		enlarge x limits=false,
		x axis line style={-stealth}
	},
	/pgfplots/every non boxed y axis/.style={%
		ytick align=center,
		enlarge y limits=false,
		y axis line style={-stealth}
	},
	/pgfplots/every non boxed z axis/.style={%
		ztick align=center,
		enlarge z limits=false,
		z axis line style={-stealth}
	},
	/pgfplots/every boxed x axis/.style={},
	/pgfplots/every boxed y axis/.style={},
	/pgfplots/every boxed z axis/.style={},
%	/pgfplots/hide axis/.belongs to family=/pgfplots,
% sets \pgfplots@xaxislinesnum to
% box=0
% bottom=1
% middle=2 ( aliased with center )
% top=3
	/pgfplots/axis x line*/.is choice,
	/pgfplots/axis x line*/box/.code	={\def\pgfplots@xaxislinesnum{0}\def\pgfplots@xtickposnum{0}},
	/pgfplots/axis x line*/bottom/.code	={\def\pgfplots@xaxislinesnum{1}\def\pgfplots@xtickposnum{1}\let\pgfplots@xticklabel@pos\pgfutil@empty},
	/pgfplots/axis x line*/left/.style={/pgfplots/axis x line*/bottom},
	/pgfplots/axis x line*/middle/.code	={\def\pgfplots@xaxislinesnum{2}\def\pgfplots@xtickposnum{2}\let\pgfplots@xticklabel@pos\pgfutil@empty},
	/pgfplots/axis x line*/center/.style	={/pgfplots/axis x line*/middle},
	/pgfplots/axis x line*/top/.code	={\def\pgfplots@xaxislinesnum{3}\def\pgfplots@xtickposnum{3}\let\pgfplots@xticklabel@pos\pgfutil@empty},
	/pgfplots/axis x line*/right/.style={/pgfplots/axis x line*/top},
	/pgfplots/axis x line*/none/.code	={\def\pgfplots@xaxislinesnum{4}\def\pgfplots@xtickposnum{4}\let\pgfplots@xticklabel@pos\pgfutil@empty},
	/pgfplots/axis x line*=box,
	%
	/pgfplots/axis x line/.is choice,
	/pgfplots/axis x line/box/.style	={
		/pgfplots/axis x line*/box,
		/pgfplots/every boxed x axis
	},
	/pgfplots/axis x line/bottom/.style	={
		/pgfplots/axis x line*/bottom,
		/pgfplots/every non boxed x axis
	},
	/pgfplots/axis x line/left/.style={/pgfplots/axis x line/bottom},%
	/pgfplots/axis x line/middle/.code	={%
		\ifnum\pgfplots@yaxislinesnum=3 % if 'axis y line==right' then
			\pgfkeysalso{/pgfplots/every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}%
		\else
			\pgfkeysalso{/pgfplots/every axis x label/.style={at={(current axis.right of origin)},anchor=south east}}%
		\fi
		\pgfkeysalso{/pgfplots/axis x line*/middle,
			/pgfplots/every non boxed x axis}%
	},
	/pgfplots/axis x line/center/.style	={/pgfplots/axis x line/middle},
	/pgfplots/axis x line/right/.style={/pgfplots/axis x line/top},%
	/pgfplots/axis x line/top/.code	={
		\ifnum\pgfplots@yaxislinesnum=2 % if 'axis y line==center' then
			\pgfkeysalso{
				/pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}%
		\fi
		\pgfkeysalso{%
			/pgfplots/axis x line*/top,
			/pgfplots/every axis x label/.style={at={(0.5,1)},anchor=south,yshift=15pt},
			/pgfplots/every non boxed x axis}%
	},
	/pgfplots/axis x line/none/.style	={axis x line*/none,hide x axis},
% sets \pgfplots@yaxislinesnum to
% box=0
% left=1
% center=2 ( aliased with middle )
% right=3
	/pgfplots/axis y line*/.is choice,
	/pgfplots/axis y line*/box/.code	={\def\pgfplots@yaxislinesnum{0}\def\pgfplots@ytickposnum{0}},
	/pgfplots/axis y line*/left/.code	={\def\pgfplots@yaxislinesnum{1}\def\pgfplots@ytickposnum{1}\let\pgfplots@yticklabel@pos\pgfutil@empty},
	/pgfplots/axis y line*/center/.code	={\def\pgfplots@yaxislinesnum{2}\def\pgfplots@ytickposnum{2}\let\pgfplots@yticklabel@pos\pgfutil@empty},
	/pgfplots/axis y line*/middle/.style	={/pgfplots/axis y line*/center},
	/pgfplots/axis y line*/right/.code	={\def\pgfplots@yaxislinesnum{3}\def\pgfplots@ytickposnum{3}\let\pgfplots@yticklabel@pos\pgfutil@empty},
	/pgfplots/axis y line*/none/.code	={\def\pgfplots@yaxislinesnum{4}\def\pgfplots@ytickposnum{4}\let\pgfplots@yticklabel@pos\pgfutil@empty},
	/pgfplots/axis y line*=box,
	%
	/pgfplots/axis y line/.is choice,
	/pgfplots/axis y line/box/.style	={
		/pgfplots/axis y line*/box,
		/pgfplots/every boxed y axis
	},
	/pgfplots/axis y line/left/.style	={
		/pgfplots/axis y line*/left,
		/pgfplots/every non boxed y axis
	},
	/pgfplots/axis y line/center/.code	={
		\ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then
			\pgfkeysalso{%
				/pgfplots/every axis y label/.style={at={(current axis.below origin)},anchor=south west}}%
		\else
			\pgfkeysalso{%
				/pgfplots/every axis y label/.style={at={(current axis.above origin)},anchor=north west}}%
		\fi
		\pgfkeysalso{%
			/pgfplots/axis y line*/center,
			/pgfplots/every non boxed y axis}%
	},
	/pgfplots/axis y line/middle/.style	={/pgfplots/axis y line/center},
	/pgfplots/axis y line/right/.code	={%
		\ifnum\pgfplots@xaxislinesnum=2
			\pgfkeysalso{every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}%
		\fi
		\pgfkeysalso{
			axis y line*/right,
			%every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt},
			% FIXME : DEPRECATED !? USE 'near tick' things ....
			every axis y label/.style={at={(1,0.5)},xshift=33pt,rotate=90},
			/pgfplots/every non boxed y axis
		}%
	},%
	/pgfplots/axis y line/none/.style	={axis y line*/none,hide y axis},
%
% sets \pgfplots@zaxislinesnum to
% box=0
% left=1
% center=2 ( aliased with middle )
% right=3
	/pgfplots/axis z line*/.is choice,
	/pgfplots/axis z line*/box/.code	={\def\pgfplots@zaxislinesnum{0}\def\pgfplots@ztickposnum{0}},
	/pgfplots/axis z line*/left/.code	={\def\pgfplots@zaxislinesnum{1}\def\pgfplots@ztickposnum{1}\let\pgfplots@zticklabel@pos\pgfutil@empty},
	/pgfplots/axis z line*/center/.code	={\def\pgfplots@zaxislinesnum{2}\def\pgfplots@ztickposnum{2}\let\pgfplots@zticklabel@pos\pgfutil@empty},
	/pgfplots/axis z line*/middle/.style	={/pgfplots/axis z line*/center},
	/pgfplots/axis z line*/right/.code	={\def\pgfplots@zaxislinesnum{3}\def\pgfplots@ztickposnum{3}\let\pgfplots@zticklabel@pos\pgfutil@empty},
	/pgfplots/axis z line*/none/.code	={\def\pgfplots@zaxislinesnum{4}\def\pgfplots@ztickposnum{4}\let\pgfplots@zticklabel@pos\pgfutil@empty},
	/pgfplots/axis z line*=box,
	%
	/pgfplots/axis z line/.is choice,
	/pgfplots/axis z line/box/.style	={
		/pgfplots/axis z line*/box,
		/pgfplots/every boxed z axis
	},
	/pgfplots/axis z line/left/.style	={
		/pgfplots/axis z line*/left,
		/pgfplots/every non boxed z axis
	},
	/pgfplots/axis z line/center/.code	={
	%	\ifnum\pgfplots@xaxislinesnum=3 % if 'axis x line==top' then
	%		\pgfkeysalso{%
	%			/pgfplots/every axis z label/.style={at={(current axis.below origin)},anchor=south west}}%
	%	\else
			\pgfkeysalso{%
				/pgfplots/every axis z label/.style={at={(current axis.above origin)},anchor=north west}}%
	%	\fi
		\pgfkeysalso{%
			/pgfplots/axis z line*/center,
			/pgfplots/every non boxed z axis}%
	},
	/pgfplots/axis z line/middle/.style	={/pgfplots/axis z line/center},
	/pgfplots/axis z line/right/.code	={%
		\ifnum\pgfplots@xaxislinesnum=2
			\pgfkeysalso{every axis x label/.style={at={(current axis.left of origin)},anchor=south west}}%
		\fi
		\pgfkeysalso{
			axis z line*/right,
			%every axis y label/.style={at={(1,1)},anchor=north west,xshift=15pt},
			every axis z label/.style={at={(1,0.5)},xshift=33pt,rotate=90},
		/pgfplots/every non boxed z axis
		}%
	},%
	/pgfplots/axis z line/none/.style	={axis z line*/none,hide z axis},
	/pgfplots/axis lines/.style={%
		axis x line=#1,%
		axis y line=#1,%
		axis z line=#1%
	},
	/pgfplots/axis lines*/.style={%
		axis x line*=#1,%
		axis y line*=#1,%
		axis z line*=#1%
	},
	/pgfplots/3d box/.is choice,
	/pgfplots/3d box/background/.code			={\def\pgfplots@threedimbox@choice{0}},%
	/pgfplots/3d box/complete/.code				={\def\pgfplots@threedimbox@choice{1}},%
	/pgfplots/3d box/complete*/.code				={\def\pgfplots@threedimbox@choice{2}},%
	/pgfplots/3d box/.default=complete,%
	/pgfplots/3d box/background,%
	/pgfplots/every 3d box foreground/.style={},
	/pgfplots/3d box foreground style/.style={%
		/pgfplots/every 3d box foreground/.append style={#1}%
	},
% set \pgfplots@xaxisdiscontnum
% none = 0
% crunch = 1
% open = 2
	/pgfplots/axis x discontinuity/.is choice,
	/pgfplots/axis x discontinuity/none/.code	={\def\pgfplots@xaxisdiscontnum{0}},
	/pgfplots/axis x discontinuity/crunch/.code	={\def\pgfplots@xaxisdiscontnum{1}},
	/pgfplots/axis x discontinuity/parallel/.code	={\def\pgfplots@xaxisdiscontnum{2}},
	/pgfplots/axis x discontinuity=none,
% set \pgfplots@yaxisdiscontnum
% none = 0
% crunch = 1
% open = 2
	/pgfplots/axis y discontinuity/.is choice,
	/pgfplots/axis y discontinuity/none/.code	={\def\pgfplots@yaxisdiscontnum{0}},
	/pgfplots/axis y discontinuity/crunch/.code	={\def\pgfplots@yaxisdiscontnum{1}},
	/pgfplots/axis y discontinuity/parallel/.code	={\def\pgfplots@yaxisdiscontnum{2}},
	/pgfplots/axis y discontinuity=none,
% set \pgfplots@yaxisdiscontnum
% none = 0
% crunch = 1
% open = 2
	/pgfplots/axis z discontinuity/.is choice,
	/pgfplots/axis z discontinuity/none/.code	={\def\pgfplots@zaxisdiscontnum{0}},
	/pgfplots/axis z discontinuity/crunch/.code	={\def\pgfplots@zaxisdiscontnum{1}},
	/pgfplots/axis z discontinuity/parallel/.code	={\def\pgfplots@zaxisdiscontnum{2}},
	/pgfplots/axis z discontinuity=none,
	/pgfplots/scale only axis/.is if=pgfplots@scale@only@axis,
	/pgfplots/scale only axis/.default=true,
	/pgfplots/scale only axis=false,
% sets \pgfplots@xislinear to
% normal=true
% log=false
	/pgfplots/xmode/.is choice,
	/pgfplots/xmode/.belongs to family=/pgfplots/scale,
	/pgfplots/xmode/normal/.code={\pgfplots@xislineartrue},
	/pgfplots/xmode/normal/.belongs to family=/pgfplots/scale,
	/pgfplots/xmode/linear/.code={\pgfplots@xislineartrue},
	/pgfplots/xmode/linear/.belongs to family=/pgfplots/scale,
	/pgfplots/xmode/log/.code={\pgfplots@xislinearfalse},
	/pgfplots/xmode/log/.belongs to family=/pgfplots/scale,
	/pgfplots/xmode=linear,
	/pgfplots/ymode/.is choice,
	/pgfplots/ymode/.belongs to family=/pgfplots/scale,
	/pgfplots/ymode/normal/.code={\pgfplots@yislineartrue},
	/pgfplots/ymode/normal/.belongs to family=/pgfplots/scale,
	/pgfplots/ymode/linear/.code={\pgfplots@yislineartrue},
	/pgfplots/ymode/linear/.belongs to family=/pgfplots/scale,
	/pgfplots/ymode/log/.code={\pgfplots@yislinearfalse},
	/pgfplots/ymode/log/.belongs to family=/pgfplots/scale,
	/pgfplots/ymode=linear,
	/pgfplots/zmode/.is choice,
	/pgfplots/zmode/.belongs to family=/pgfplots/scale,
	/pgfplots/zmode/normal/.code={\pgfplots@zislineartrue},
	/pgfplots/zmode/normal/.belongs to family=/pgfplots/scale,
	/pgfplots/zmode/linear/.code={\pgfplots@zislineartrue},
	/pgfplots/zmode/linear/.belongs to family=/pgfplots/scale,
	/pgfplots/zmode/log/.code={\pgfplots@zislinearfalse},
	/pgfplots/zmode/log/.belongs to family=/pgfplots/scale,
	/pgfplots/zmode=linear,
	/pgfplots/error bars/x fixed/.code=				\def\pgfplots@errorbars@xfixed{#1}\def\pgfplots@errorbars@xmode{0},
	/pgfplots/error bars/x fixed relative/.code=		\def\pgfplots@errorbars@xrel{#1}\def\pgfplots@errorbars@xmode{1},
	/pgfplots/error bars/x explicit/.code=			\def\pgfplots@errorbars@xmode{2},
	/pgfplots/error bars/x explicit relative/.code=	\def\pgfplots@errorbars@xmode{3},
	/pgfplots/error bars/x fixed relative=0,
	/pgfplots/error bars/x fixed=0,
	/pgfplots/error bars/y fixed/.code=				\def\pgfplots@errorbars@yfixed{#1}\def\pgfplots@errorbars@ymode{0},
	/pgfplots/error bars/y fixed relative/.code=		\def\pgfplots@errorbars@yrel{#1}\def\pgfplots@errorbars@ymode{1},
	/pgfplots/error bars/y explicit/.code=			\def\pgfplots@errorbars@ymode{2},
	/pgfplots/error bars/y explicit relative/.code=	\def\pgfplots@errorbars@ymode{3},
	/pgfplots/error bars/y fixed relative=0,
	/pgfplots/error bars/y fixed=0,
	/pgfplots/error bars/z fixed/.code=				\def\pgfplots@errorbars@zfixed{#1}\def\pgfplots@errorbars@zmode{0},
	/pgfplots/error bars/z fixed relative/.code=		\def\pgfplots@errorbars@zrel{#1}\def\pgfplots@errorbars@zmode{1},
	/pgfplots/error bars/z explicit/.code=			\def\pgfplots@errorbars@zmode{2},
	/pgfplots/error bars/z explicit relative/.code=	\def\pgfplots@errorbars@zmode{3},
	/pgfplots/error bars/z fixed relative=0,
	/pgfplots/error bars/z fixed=0,
	/pgfplots/error bars/x dir/.is choice,
	/pgfplots/error bars/x dir/none/.code={%
		\def\pgfplots@errorbars@xdirection{0}%
		\ifnum\pgfplots@errorbars@ydirection=0
			\ifnum\pgfplots@errorbars@zdirection=0
				\pgfplots@errorbars@enabledfalse
			\fi
		\fi
	},
	/pgfplots/error bars/x dir/plus/.code=				\def\pgfplots@errorbars@xdirection{1}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/x dir/minus/.code=				\def\pgfplots@errorbars@xdirection{2}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/x dir/both/.code=				\def\pgfplots@errorbars@xdirection{3}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/x dir=none,
	/pgfplots/error bars/y dir/.is choice,
	/pgfplots/error bars/y dir/none/.code={%
		\def\pgfplots@errorbars@ydirection{0}%
		\ifnum\pgfplots@errorbars@xdirection=0
			\ifnum\pgfplots@errorbars@zdirection=0
				\pgfplots@errorbars@enabledfalse
			\fi
		\fi
	},
	/pgfplots/error bars/y dir/plus/.code=				\def\pgfplots@errorbars@ydirection{1}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/y dir/minus/.code=				\def\pgfplots@errorbars@ydirection{2}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/y dir/both/.code=				\def\pgfplots@errorbars@ydirection{3}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/y dir=none,
	/pgfplots/error bars/z dir/.is choice,
	/pgfplots/error bars/z dir/none/.code={%
		\def\pgfplots@errorbars@zdirection{0}%
		\ifnum\pgfplots@errorbars@xdirection=0
			\ifnum\pgfplots@errorbars@ydirection=0
				\pgfplots@errorbars@enabledfalse
			\fi
		\fi
	},
	/pgfplots/error bars/z dir/plus/.code=				\def\pgfplots@errorbars@zdirection{1}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/z dir/minus/.code=				\def\pgfplots@errorbars@zdirection{2}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/z dir/both/.code=				\def\pgfplots@errorbars@zdirection{3}\pgfplots@errorbars@enabledtrue,
	/pgfplots/error bars/z dir=none,
	/pgfplots/error bars/error mark/.initial={-},
	/pgfplots/error bars/error mark options/.initial={rotate=90},
	/pgfplots/error bars/error bar style/.code={%
		\pgfkeysalso{/pgfplots/every error bar/.append style={#1}}%
	},
	/pgfplots/every error bar/.style={thin},
	/pgfplots/every error bar/.append code={\pgfplotsdeprecatedstylecheck{/tikz/every error bar}},
	/pgfplots/error bars/draw error bar/.code 2 args={%
%\message{/pgfplots/error bars/draw error bar:  working with '#1' -- '#2'.}%
		\pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
		\pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
		\draw #1 -- #2 node[pos=1,sloped,allow upside down] {%
			\expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
				\expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
				\pgfusepath{stroke}}%
		};
	},
	/pgfplots/every node near coord/.style={},
	% values: 'horizontal', 'vertical' or any tikz alignment command
	% like 'left' or 'anchor=south west' or so.
	/pgfplots/nodes near coords align/.initial=auto,%
	%
	% 'nodes near coords=<content of node>'.
	% The content is by default \pgfmathprintnumber\pgfplotspointmeta.
	% 
	% Use 'point meta=y' after 'nodes near coords' to typeset the y coordinates 
	% Use 'point meta=x' to typeset the x coordinates 
	/pgfplots/nodes near coords/.style={%
		/pgfplots/scatter/@pre marker code/.code={},%
		/pgfplots/scatter/@post marker code/.code={},%
		/pgfplots/nodes near coords*={#1},%
	},%
	/pgfplots/nodes near coords*/.style={%
		/pgfplots/scatter/true*,%
		/pgfplots/set point meta if empty=f(x),%
		scatter/@post marker code/.append code={%
			% determine default alignment:
			\pgfkeysgetvalue{/pgfplots/nodes near coords align}{\pgfplots@nodes@near@coords@align}%
			\edef\pgfplots@nodes@near@coords@align{\pgfplots@nodes@near@coords@align}%
			\def\pgfplots@loc@TMPa{auto}%
			\ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa
				\ifx\pgfplotspointmetainputhandler x%
					% point meta=x:
					\def\pgfplots@nodes@near@coords@align{horizontal}%
				\else
					\def\pgfplots@nodes@near@coords@align{vertical}%
				\fi
			\fi
			% check for sign-dependand alignment options:
			\def\pgfplots@loc@TMPa{horizontal}%
			\ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa
				\if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname%
					\def\pgfplots@nodes@near@coords@align{above}%
				\else
					\pgfmathfloatifflags{\pgfplotspointmeta}{2}{%
						% \pgfplotspointmeta < 0
						\def\pgfplots@nodes@near@coords@align{left}%
					}{%
						% \pgfplotspointmeta >= 0
						\def\pgfplots@nodes@near@coords@align{right}%
					}%
				\fi
			\else
				\def\pgfplots@loc@TMPa{vertical}%
				\ifx\pgfplots@nodes@near@coords@align\pgfplots@loc@TMPa
					\if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname%
						\def\pgfplots@nodes@near@coords@align{above}%
					\else
						\pgfmathfloatifflags{\pgfplotspointmeta}{2}{%
							% \pgfplotspointmeta < 0
							\def\pgfplots@nodes@near@coords@align{below}%
						}{%
							% \pgfplotspointmeta >= 0
							\def\pgfplots@nodes@near@coords@align{above}%
						}%
					\fi
				\else
					\pgfutil@ifundefined{pgfplots@nodesnearcoordsalign@isanchor@\pgfplots@nodes@near@coords@align}
					{}%
					{%
						\t@pgfplots@toka=\expandafter{\pgfplots@nodes@near@coords@align}%
						\edef\pgfplots@nodes@near@coords@align{anchor=\the\t@pgfplots@toka}%
					}%
				\fi
			\fi
			% ok, place the node.
			\expandafter\node\expandafter[\pgfplots@nodes@near@coords@align,%
				/pgfplots/every node near coord] 
				at (0pt,0pt) 
			{%
				\if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname%
					% point meta=explicit symbolic
					% do not try to invoke \pgfmathprintnumber on
					% symbolic data... this check should keep the user
					% interface simpler.
					\def\pgfplots@loc@TMPa{\pgfmathprintnumber\pgfplotspointmeta}%
					\def\pgfplots@loc@TMPb{#1}%
					\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
						\pgfplotspointmeta
					\else
						#1%
					\fi
				\else
					#1%
				\fi
			};
		},%
	},%
	/pgfplots/nodes near coords*/.default={\pgfmathprintnumber\pgfplotspointmeta},
	/pgfplots/bar cycle list/.style={/pgfplots/cycle list={%
		{blue,fill=blue!30!white,mark=none},%
		{red,fill=red!30!white,mark=none},%
		{brown!60!black,fill=brown!30!white,mark=none},%
		{black,fill=gray,mark=none},%
		}
	},
	/pgfplots/area cycle list/.style={bar cycle list},
	/pgfplots/area legend/.style={%
		/pgfplots/legend image code/.code={%
			\draw[##1] (0cm,-0.1cm) rectangle (0.6cm,0.1cm);
		}%
	},
	/pgfplots/area style/.style={%
		area cycle list,
		area legend,
		axis on top,
	},
	/pgfplots/ybar legend/.style={
		/pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};},
	},
	/pgfplots/ybar/.style={
		bar cycle list,
		xtick align=outside,
		ybar legend,
		/pgfplots/set point meta if empty=f(x),%
		/pgf/bar shift={%
				% total width = n*w + (n-1)*skip
				% -> subtract half for centering
				-0.5*(\numplotsofactualtype*\pgfplotbarwidth + (\numplotsofactualtype-1)*#1)  + 
				% the '0.5*w' is for centering
				(.5+\plotnumofactualtype)*\pgfplotbarwidth + \plotnumofactualtype*#1},%
		/pgfplots/error bars/draw error bar/.code 2 args={%
% FIXME: simplify this code! It is just a replication of the default error stuff together with an xshift!
			\pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
			\pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
			\draw[xshift={\pgfkeysvalueof{/pgf/bar shift}}]
				##1 -- ##2 node[pos=1,sloped,allow upside down] {%
				\expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
					\expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
					\pgfusepath{stroke}}%
			};
		},%
		/pgfplots/every node near coord/.append style={xshift={\pgfkeysvalueof{/pgf/bar shift}}},%
		/tikz/ybar,
	},
	/pgfplots/ybar/.default=2pt,
	/pgfplots/xbar legend/.style={
		/pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,bar width=3pt,yshift=-0.2em,bar shift=0pt] plot coordinates {(0cm,0.8em) (2*\pgfplotbarwidth,0.6em)};},
	},
	/pgfplots/xbar/.style={
		bar cycle list,
		ytick align=outside,
		/pgfplots/xbar legend,
		/pgfplots/set point meta if empty=x,%
		/pgf/bar shift={%
				% total width = n*w + (n-1)*skip
				% -> subtract half for centering
				-0.5*(\numplotsofactualtype*\pgfplotbarwidth + (\numplotsofactualtype-1)*#1)  + 
				% the '0.5*w' is for centering
				(.5+\plotnumofactualtype)*\pgfplotbarwidth + \plotnumofactualtype*#1},%
		/pgfplots/error bars/draw error bar/.code 2 args={%
% FIXME: simplify this code! It is just a replication of the default error stuff together with an xshift!
			\pgfkeysgetvalue{/pgfplots/error bars/error mark}{\pgfplotserrorbarsmark}%
			\pgfkeysgetvalue{/pgfplots/error bars/error mark options}{\pgfplotserrorbarsmarkopts}%
			\draw[yshift={\pgfkeysvalueof{/pgf/bar shift}}]
				##1 -- ##2 node[pos=1,sloped,allow upside down] {%
				\expandafter\tikz\expandafter[\pgfplotserrorbarsmarkopts]{%
					\expandafter\pgfuseplotmark\expandafter{\pgfplotserrorbarsmark}%
					\pgfusepath{stroke}}%
			};
		},%
		/pgfplots/every node near coord/.append style={yshift={\pgfkeysvalueof{/pgf/bar shift}}},%
		/tikz/xbar,
	},
	/pgfplots/xbar/.default=2pt,
	/pgfplots/ybar interval legend/.style={
		/pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};},
	},
	/pgfplots/ybar interval/.style={%
		/pgfplots/set point meta if empty=f(x),%
		bar cycle list,
		x tick label as interval,
		xmajorgrids,
		xtick align=outside,
		xtick=data,
		ybar interval legend,
		bar interval width={#1/\numplotsofactualtype},
		bar interval shift={(\plotnumofactualtype+0.5)/\numplotsofactualtype},
		/tikz/ybar interval,
	},
	/pgfplots/ybar interval/.default=1,
	/pgfplots/xbar interval legend/.style={%
		/pgfplots/legend image code/.code={\draw[##1,/tikz/.cd,yshift=-0.2em,bar interval width=0.7,bar interval shift=0.5] plot coordinates {(0cm,0.8em) (5pt,0.6em) (10pt,0.6em)};},
	},
	/pgfplots/xbar interval/.style={%
		/pgfplots/set point meta if empty=x,%
		bar cycle list,
		y tick label as interval,
		ytick=data,
		ymajorgrids,
		ytick align=outside,
		xbar interval legend,
		bar interval width={#1/\numplotsofactualtype},
		bar interval shift={(\plotnumofactualtype+0.5)/\numplotsofactualtype},
		/tikz/xbar interval,
	},
	/pgfplots/xbar interval/.default=1,
	/pgfplots/xbar stacked/.style={
		/pgfplots/set point meta if empty=x,%
		bar cycle list,
		stack plots=x,
		stack dir=#1,
		/tikz/xbar,
	},
	/pgfplots/xbar stacked/.default=plus,
	/pgfplots/ybar stacked/.style={
		/pgfplots/set point meta if empty=f(x),%
		bar cycle list,
		stack plots=y,
		stack dir=#1,
		/tikz/ybar,
	},
	/pgfplots/ybar stacked/.default=plus,
	/pgfplots/xbar interval stacked/.style={
		/pgfplots/set point meta if empty=x,%
		bar cycle list,
		stack plots=x,
		stack dir=#1,
		/tikz/xbar interval,
	},
	/pgfplots/xbar interval stacked/.default=plus,
	/pgfplots/ybar interval stacked/.style={
		/pgfplots/set point meta if empty=f(x),%
		bar cycle list,
		stack plots=y,
		stack dir=#1,
		/tikz/ybar interval,
	},
	/pgfplots/ybar interval stacked/.default=plus,
	/pgfplots/yticklabel interval boundaries/.style={%
		y tick label as interval,
		yticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$}
	},
	/pgfplots/xticklabel interval boundaries/.style={%
		x tick label as interval,
		xticklabel={$\pgfmathprintnumber{\tick}$ -- $\pgfmathprintnumber{\nexttick}$}
	},
	/pgfplots/plot file/skip first/.is if=pgfplots@plot@file@skipfirst,
	/pgfplots/plot file/skip first/.default=true,
	/pgfplots/plot file/ignore first/.style={/pgfplots/plot file/skip first={#1}},
	/pgfplots/plot file/.search also=/pgfplots,%
	/pgfplots/plot coordinates/math parser/.is if=pgfplots@plot@coords@mathparser,
	/pgfplots/plot graphics/.code={\let\tikz@plot@handler=\pgfplotsplothandlergraphics},%
	/pgfplots/plot graphics/src/.initial=,
	/pgfplots/plot graphics/includegraphics/.initial=,
	/pgfplots/plot graphics/includegraphics cmd/.initial=\includegraphics,
	/pgfplots/plot graphics/xmin/.initial=,
	/pgfplots/plot graphics/xmax/.initial=,
	/pgfplots/plot graphics/ymin/.initial=,
	/pgfplots/plot graphics/ymax/.initial=,
	/pgfplots/plot graphics/zmin/.initial=,
	/pgfplots/plot graphics/zmax/.initial=,
	/pgfplots/plot graphics/lowlevel draw/.code 2 args={%
		\pgfplots@plot@handler@graphics@DRAW{#1}{#2}%
	},%
	/pgfplots/plot graphics/node/.style={
		transform shape,
		inner sep=0pt,
		outer sep=0pt,
		every node/.style={},
		anchor=south west,
		at={(0pt,0pt)},
		rectangle
	},
	% 'mesh' plots.
	% The macro \pgfplots@meshmode is
	% n if meshmode == false,
	% m if meshmode == 'mesh',
	% s if meshmode == 'surf'.
	%
	% The type of surface plot can be configured with 'shader'.
	/pgfplots/mesh/.is choice,
	/pgfplots/mesh/true/.code={%
		\def\pgfplots@meshmode{m}%
		\let\tikz@plot@handler=\pgfplotsplothandlermesh
		\pgfkeysalso{/pgfplots/set point meta if empty=f(x),/pgfplots/every mesh,/pgfplots/mesh legend,/tikz/color=mapped color}%
	},
	/pgfplots/mesh/false/.code={
		\def\pgfplots@meshmode{n}%
		\ifx\tikz@plot@handler\pgfplotsplothandlermesh
			\let\tikz@plot@handler=\pgfplothandlerlineto
		\fi},
	/pgfplots/mesh/.default=true,
	/pgfplots/surf/.code={%
		\pgfkeysalso{/pgfplots/mesh=#1}%
		\def\pgfplots@meshmode{s}%
	},%
	/pgfplots/mesh/rows/.initial=,
	/pgfplots/mesh/cols/.initial=,
	/pgfplots/mesh/scanline verbose/.is if=pgfplots@scanline@verbose,%
	/pgfplots/mesh/scanline verbose/.default=true,
	/pgfplots/mesh/check/.code={%
		\pgfplotsutilifstringequal{#1}{false}{%
			\def\pgfplots@mesh@checkmode{0}%
		}{%
			\pgfplotsutilifstringequal{#1}{warning}{%
				\def\pgfplots@mesh@checkmode{1}%
			}{%
				\pgfplotsutilifstringequal{#1}{error}{%
					\def\pgfplots@mesh@checkmode{2}%
				}{%
					\pgfplots@error{Invalid value `#1' for /pgfplots/mesh/check. Please use one of false,warning,error}%
				}%
			}%
		}%
	},%
	/pgfplots/mesh/check=error,
	/pgfplots/mesh/ordering/.is choice,
	/pgfplots/mesh/ordering/x varies/.code={\def\pgfplots@plot@mesh@ordering{0}},
	/pgfplots/mesh/ordering/y varies/.code={\def\pgfplots@plot@mesh@ordering{1}},
	/pgfplots/mesh/ordering/rowwise/.style={/pgfplots/mesh/ordering/x varies},
	/pgfplots/mesh/ordering/colwise/.style={/pgfplots/mesh/ordering/y varies},
	/pgfplots/mesh/ordering/x varies,
	/pgfplots/every mesh/.code={%
		% is slower:
		%\pgfkeysalso{/pgfplots/unbounded coords=jump}% mesh plots need balanced cols!
	},%
	/pgfplots/mesh legend/.style={%
		/pgfplots/legend image code/.code={%
			\pgfplotsplothandlermesh@defaultlegend@img{##1}%
		}%
	},
	/pgfplots/mesh/num points/.initial=\numcoords,% this is NOT part of the public interface. Don't change it.
	/pgfplots/z buffer/.is choice,%
	/pgfplots/z buffer/none/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{0}},%
	/pgfplots/z buffer/reverse x seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{1}},%
	/pgfplots/z buffer/reverse y seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{2}},%
	/pgfplots/z buffer/reverse xy seq/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{3}},%
	/pgfplots/z buffer/sort/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{4}},%
	/pgfplots/z buffer/auto/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{5}},%
	/pgfplots/z buffer/default/.code={\def\pgfplotsplothandlermesh@zbuffer@choice{6}},%
	/pgfplots/z buffer/default,%
	%
	% Set the shader used for surface plots.
	% RULES:
	% 	1. meshmode == 'm' (mesh):  
	% 		This means we use "shader/flat" to determine the colors
	% 		and ignore fill colors.
	% 	2. meshmode == 's' (surf):
	% 		the shader specifies how colors are used.
	% 	3. Onedimensional mesh/surf plots are treated like 'mesh'
	% 	plots.
	/pgfplots/shader/.is choice,
	/pgfplots/shader/flat corner/.code={\def\pgfplotsplothandlermesh@shader{0}\def\pgfplotsplothandlermesh@flatmode{c}},
	/pgfplots/shader/flat mean/.code={\def\pgfplotsplothandlermesh@shader{0}\def\pgfplotsplothandlermesh@flatmode{m}},
	/pgfplots/shader/flat/.style={/pgfplots/shader/flat mean},%
	/pgfplots/shader/faceted/.code={\def\pgfplotsplothandlermesh@shader{1}},
	/pgfplots/shader/interp/.code={\def\pgfplotsplothandlermesh@shader{2}},
	/pgfplots/shader/faceted,
	/pgfplots/faceted color/.initial=mapped color!80!black,
	/pgfplots/clip marker paths/.is if=pgfplots@clip@marker@paths,
	/pgfplots/clip marker paths/.default=true,
	/pgfplots/axis on top/.is if=pgfplots@axis@on@top,
	/pgfplots/axis on top/.default=true,
	/pgfplots/invoke before crossref tikzpicture/.initial={%
		\expandafter\ifx\csname tikzappendtofigurename\endcsname\relax
		\else
			\begingroup
			\tikzappendtofigurename{_crossref}%
		\fi
	},
	/pgfplots/invoke after crossref tikzpicture/.initial={%
		\expandafter\ifx\csname tikzappendtofigurename\endcsname\relax
		\else
			\endgroup
		\fi
	},%
	/pgfplots/every crossref picture/.style={%
		baseline,yshift=0.3em
	},
	/pgfplots/unbounded coords/.code={%
		\edef\pgfplots@loc@TMPa{#1}%
		\def\pgfplots@loc@TMPb{discard}%
		\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
			\def\pgfplots@unbounded@handler{d}%
		\else
			\def\pgfplots@loc@TMPb{jump}%
			\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				\def\pgfplots@unbounded@handler{j}%
			\else
				\pgfplots@error{Sorry, the choice `#1' is unknown for \pgfkeyscurrentkey. Please use either 'discard' or 'jump'.}%
			\fi
		\fi
	},%
	/pgfplots/unbounded coords=discard,
	/pgfplots/x coord trafo/.code={},
	/pgfplots/x coord inv trafo/.code={},
	/pgfplots/y coord trafo/.code={},
	/pgfplots/y coord inv trafo/.code={},
	/pgfplots/z coord trafo/.code={},
	/pgfplots/z coord inv trafo/.code={},
	%
 	% #1 = {<symbol1>,<symbol2>,....<symboln>}
	/pgfplots/symbolic coords/.code 2 args={%
		\pgfplotsarraynew\pgfplots@symbolic@coords@inverse{#2}%
		\pgfplotsarrayforeachungrouped\pgfplots@symbolic@coords@inverse\as\pgfplots@loc@TMPa{%
			\expandafter\edef\csname pgfp@symb@coords@\pgfplots@loc@TMPa\endcsname{\pgfplotsarrayforeachindex}%
		}%
		\pgfkeysdef{/pgfplots/#1 coord trafo}{%
			\pgfutil@ifundefined{pgfp@symb@coords@##1}{%
				\pgfplots@error{Sorry, the input coordinate `##1' has not been defined with 'symbolic #1 coords={#2}... Maybe it has been misspelled?}%
				\def\pgfmathresult{0}%
			}{%
				\edef\pgfmathresult{\csname pgfp@symb@coords@##1\endcsname}%
			}%
		}%
		\pgfkeysdef{/pgfplots/#1 coord inv trafo}{%
			\begingroup
			% discard everything up to the period:
			\pgfmath@basic@round@{##1}%
			\afterassignment\pgfplots@gobble@until@relax
			\count0=\pgfmathresult\relax
			\ifnum\count0<0
				\count0=0
			\else
				\count1=\pgfplotsarraysizeof\pgfplots@symbolic@coords@inverse\relax
				\ifnum\count0<\count1
				\else
					\count0=\count1
					\advance\count0 by-1
				\fi
			\fi
			\pgfplotsarrayselect\count0 \of\pgfplots@symbolic@coords@inverse\to\pgfmathresult
			\pgfmath@smuggleone\pgfmathresult
			\endgroup
		}%
		\pgfkeysalso{%
			/pgfplots/#1ticklabel={\tick},%
			/pgfplots/scaled #1 ticks=false,%
			/pgfplots/plot coordinates/math parser=false,%
		}%
	},%
	/pgfplots/symbolic x coords/.style={symbolic coords={x}{#1}},%
	/pgfplots/symbolic y coords/.style={symbolic coords={y}{#1}},%
	/pgfplots/symbolic z coords/.style={symbolic coords={z}{#1}},%
% Defines the class name \pgfplotspointmetainputhandler:
	/pgfplots/point meta/.code={%
		\pgfplots@pgfkeys@set@point@meta@value{#1}%
	},%
	/pgfplots/point meta/none/.code	={\pgfplotssetpointmetainput{}{}},%
	/pgfplots/point meta/x/.code	={\pgfplotssetpointmetainput{x}{}},%
	/pgfplots/point meta/y/.code	={\pgfplotssetpointmetainput{y}{}},%
	/pgfplots/point meta/z/.code	={\pgfplotssetpointmetainput{z}{}},%
	/pgfplots/point meta/expr/.code={\pgfplotssetpointmetainput{expr}{#1}},%
	/pgfplots/point meta/explicit/.code={\pgfplotssetpointmetainput{explicit}{}},%
	/pgfplots/point meta/explicit symbolic/.code={\pgfplotssetpointmetainput{explicit symbolic}{}},%
	/pgfplots/point meta/f(x)/.code={\pgfplotssetpointmetainput{f(x)}{}},%
	/pgfplots/point meta/TeX code/.code={\pgfplotssetpointmetainput{TeX code}{#1}},%
	/pgfplots/point meta/TeX code/.value required,
	/pgfplots/point meta/TeX code symbolic/.code={\pgfplotssetpointmetainput{TeX code symbolic}{#1}},%
	/pgfplots/point meta/TeX code symbolic/.value required,
	/pgfplots/set point meta if empty/.code={%
		\ifx\pgfplotspointmetainputhandler\pgfutil@empty
			\pgfkeysalso{/pgfplots/point meta/#1}%
		\fi
	},%
	/pgfplots/point meta/none,
	/pgfplots/point meta rel/.is choice,
	/pgfplots/point meta rel/axis wide/.code={\def\pgfplots@perpointmeta@rel@choice{0}},%
	/pgfplots/point meta rel/per plot/.code={\def\pgfplots@perpointmeta@rel@choice{1}},%
	/pgfplots/point meta rel/axis wide,%
	/pgfplots/point meta min/.initial=,%
	/pgfplots/point meta max/.initial=,%
	/pgfplots/colormap name/.initial=hot,
	/pgfplots/colormap access/.is choice,
	/pgfplots/colormap access/direct/.code={\def\pgfplots@colormap@access{d}},%
	/pgfplots/colormap access/map/.code={\def\pgfplots@colormap@access{m}},%
	/pgfplots/colormap access/map,%
	/pgfplots/colormap/.code 2 args={%
		\pgfplotscreatecolormap{#1}{#2}%
		\pgfkeysalso{/pgfplots/colormap name=#1}%
	},
	/pgfplots/colormap/hot/.style={
		colormap name=hot
	},
	/pgfplots/colormap/bluered/.style={
		/pgfplots/colormap={bluered}{rgb255(0cm)=(0,0,180); rgb255(1cm)=(0,255,255); rgb255(2cm)=(100,255,0); rgb255(3cm)=(255,255,0); rgb255(4cm)=(255,0,0); rgb255(5cm)=(128,0,0)}
	},
	/pgfplots/colormap/cool/.style={
		/pgfplots/colormap={cool}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(0,128,255); rgb255(2cm)=(255,0,255)}
	},
	/pgfplots/colormap/greenyellow/.style={
		/pgfplots/colormap={greenyellow}{rgb255(0cm)=(0,128,0); rgb255(1cm)=(255,255,0)}
	},
	/pgfplots/colormap/redyellow/.style={
		/pgfplots/colormap={redyellow}{rgb255(0cm)=(255,0,0); rgb255(1cm)=(255,255,0)}
	},
	/pgfplots/colormap/blackwhite/.style={
		colormap={blackwhite}{gray(0cm)=(0); gray(1cm)=(1)}
	},
	/pgfplots/colormap/violet/.style={
		colormap={violet}{rgb255=(25,25,122) color=(white) rgb255=(238,140,238)}
	},
	/pgfplots/scatter/.is choice,
	/pgfplots/scatter/false/.code={%
		\pgfplots@scatterplotenabledfalse
	},%
	/pgfplots/scatter/true*/.code={%
		\pgfplots@scatterplotenabledtrue
		\pgfkeysalso{/pgfplots/set point meta if empty=f(x)}%
	},%
	/pgfplots/scatter/true/.code={%
		\pgfplots@scatterplotenabledtrue
		\pgfkeysalso{/pgfplots/set point meta if empty=f(x)}%
		% make sure there is a mark set!
		\pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}%
		\def\pgfplots@loc@TMPa{none}%
		\ifx\tikz@plot@mark\pgfplots@loc@TMPa
			% this here happens only in older versions of pgf.
			\pgfqkeys{/tikz}{mark=*}%
		\else
			\ifx\tikz@plot@mark\pgfutil@empty
				\pgfqkeys{/tikz}{mark=*}%
			\fi
		\fi
	},
	/pgfplots/scatter/.default=true,
	/pgfplots/scatter src/.style={/pgfplots/point meta={#1}},
	/tikz/scatter/.style={/pgfplots/scatter=#1},
	%
	% ARGUMENTS: the macros
	% - \pgfplotspointmeta
	% - \pgfplotspointmetarange
	% - \pgfplotspointmetatransformed
	% - \pgfplotspointmetatransformedrange
	% are set during @pre marker code and @post marker code.
	% '#1' is empty.
	/pgfplots/scatter/@pre marker code/.code=,%
	/pgfplots/scatter/@post marker code/.code=,%
	/pgfplots/scatter/use mapped color/.style={%
		/pgfplots/scatter/@pre marker code/.code=,%
		/pgfplots/scatter/@post marker code/.code=,%
		/pgfplots/scatter/use mapped color*={#1},%
	},%
	/pgfplots/scatter/use mapped color*/.style={
		/pgfplots/scatter/@pre marker code/.append code={
			\pgfplotscolormapdefinemappedcolor\pgfplotspointmetatransformed
			\scope[#1]%
		},
		/pgfplots/scatter/@post marker code/.prefix code={\endscope}
	},
	/pgfplots/scatter/use mapped color*/.default={draw=mapped color!80!black,fill=mapped color},
	/pgfplots/scatter/use mapped color*,
	% expect '#1 = {<class>=<style>,<class>=<style>,...} where <class>
	% is expected as SYMBOL, not as number. See 'point meta/explicit symbolic'
	/pgfplots/scatter/classes/.style={%
		/pgfplots/scatter/@pre marker code/.code=,%
		/pgfplots/scatter/@post marker code/.code=,%
		/pgfplots/scatter/classes*={#1},%
	},%
	/pgfplots/scatter/classes*/.code={%
		% Step 1: remember the per class-styles as
		% \csname pgfp@scatter@class@<class name>\endcsname
		% -> this is done locally!
		\def\pgfplots@loc@TMPa##1=##2\pgfplots@EEOI{%
			\expandafter\def\csname pgfp@scatter@class@##1\endcsname{##2}%
		}%
		\pgfplotsforeachentryinCSV{\pgfplots@loc@TMPb}{#1}{%
			\expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb\pgfplots@EEOI
		}%
		%
		\pgfkeysalso{%
			/pgfplots/scatter/@pre marker code/.append code={\pgfplots@scatter@classes@pre@marker@code},%
			/pgfplots/scatter/@post marker code/.prefix code={\endscope}%
		}%
		% Now:remember the classes.
		\pgfkeyssetvalue{/pgfplots/scatter/classes/values}{#1}% 
		%
		% and generate legend items for every single class,
		% But ONLY if we really *have* a plot which uses
		% scatter/classes!
		\pgfkeys{/pgfplots/execute at begin plot@@/.add={}{%
				\ifpgfplots@scatterplotenabled
					\pgfkeysgetvalue{/pgfplots/scatter/@pre marker code/.@cmd}\pgfplots@loc@TMPa
					\def\pgfplots@loc@TMPb{\pgfutil@in@{\pgfplots@scatter@classes@pre@marker@code}}%
					\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa\pgfeov}%
					\ifpgfutil@in@
						% modify '\pgfplots@rememberplotspec' such
						% that it generates entries for every class:
						\let\pgfplots@rememberplotspec@orig=\pgfplots@rememberplotspec
						\def\pgfplots@rememberplotspec##1{%
							\def\pgfplots@scatter@loc@TMPa####1=####2\pgfplots@EEOI{%
								\pgfplots@rememberplotspec@orig{##1,####2}%
								\pgfplots@rememberplotspec@for@label[####1]{##1,####2}%
							}%
							\pgfplotsforeachentryinCSV{\pgfplots@scatter@loc@TMPb}{#1}{%
								\expandafter\pgfplots@scatter@loc@TMPa\pgfplots@scatter@loc@TMPb\pgfplots@EEOI
							}%
						}%
					\fi
				\fi
			}%
		}%
	},
	/pgfplots/refstyle/.code={%
		\pgfutil@ifundefined{pgfplots@labelstyle@#1}{%
			\G@refundefinedtrue
			\@latex@warning{Reference `#1' on page \thepage \space undefined}%
		}{%
			\t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfplots@labelstyle@#1\endcsname}%
			\expandafter\pgfkeysalso\expandafter{\the\t@pgfplots@toka}%
		}%
	},%
	/pgfplots/forget plot/.is if=pgfplots@curplot@isirrelevant,
	/pgfplots/forget plot/.default=true,
	/pgfplots/normalsize/.style={
		/pgfplots/width=240pt,
		/pgfplots/height=207pt,
		/pgfplots/max space between ticks=35,
	},
	/pgfplots/small/.style={
		width=6.5cm,
		height=,
		tick label style={font=\footnotesize},
		label style={font=\small},
		max space between ticks=25,
	},
	/pgfplots/footnotesize/.style={
		width=5cm,
		height=,
		legend style={font=\footnotesize},
		tick label style={font=\footnotesize},
		label style={font=\small},
		title style={font=\small},
		every axis title shift=0pt,
		max space between ticks=15,
		every mark/.append style={mark size=8},
		major tick length=0.1cm,
		minor tick length=0.066cm,
	},
	/pgfplots/tiny/.style={
		width=4cm,
		height=,
		legend style={font=\tiny},
		tick label style={font=\tiny},
		label style={font=\tiny},
		title style={font=\footnotesize},
		every axis title shift=0pt,
		max space between ticks=12,
		every mark/.append style={mark size=6},
		major tick length=0.1cm,
		minor tick length=0.066cm,
		every legend image post/.append style={scale=0.8},
    },
	/pgfplots/cube/set size/.code 2 args={%
		\expandafter\def\csname pgfplots@cube@gethalf@#1\endcsname{%
			\afterassignment\pgfplots@gobble@until@relax
			\pgfplots@tmpa=#2pt\relax
			\pgfplotsconvertunittocoordinate #1{0.5\pgfplots@tmpa}%
		}%
	},%
	/pgfplots/cube/size x/.style={/pgfplots/cube/set size=x{#1}},
	/pgfplots/cube/size y/.style={/pgfplots/cube/set size=y{#1}},
	/pgfplots/cube/size z/.style={/pgfplots/cube/set size=z{#1}},
	/pgfplots/cube/size x=\pgfplotmarksize,
	/pgfplots/cube/size y=\pgfplotmarksize,
	/pgfplots/cube/size z=\pgfplotmarksize,
	/pgfplots/xtick placement tolerance/.initial=0.05pt,
	/pgfplots/ytick placement tolerance/.initial=0.05pt,
	/pgfplots/ztick placement tolerance/.initial=0.05pt,
	%
	/pgfplots/compat/anchors/.is choice,
	/pgfplots/compat/anchors/pre 1.3/.code={\pgfplots@deprecated@anchorstrue},% FIXME: WAS \global
	/pgfplots/compat/anchors/1.3/.code= {\pgfplots@deprecated@anchorsfalse},%
	/pgfplots/compat/anchors/1.4/.style= 	{/pgfplots/compat/anchors/1.3},%
	/pgfplots/compat/anchors/newest/.style= {/pgfplots/compat/anchors/1.3},%
	/pgfplots/compat/anchors/default/.style={/pgfplots/compat/anchors/1.3},%
	/pgfplots/compat/labels/.is choice,
	/pgfplots/compat/labels/pre 1.3/.style={%
		/pgfplots/xlabel absolute,
		/pgfplots/ylabel absolute},%
	/pgfplots/compat/labels/1.3/.style={%
		/pgfplots/xlabel near ticks,
		/pgfplots/ylabel near ticks},%
	/pgfplots/compat/labels/1.4/.style=		{/pgfplots/compat/labels/1.3},%
	/pgfplots/compat/labels/newest/.style=	{/pgfplots/compat/labels/1.3},%
	/pgfplots/compat/labels/default/.style=	{/pgfplots/compat/labels/pre 1.3},% maintain backwards compatibility for labels :-(
	/pgfplots/compat/.style={%
		/pgfplots/compat/anchors=#1,%
		/pgfplots/compat/labels=#1,%
	},%
	/pgfplots/compat/.default=pre 1.3,%
	/pgfplots/compat=default,%
	%
	/pgfplots/show outer normals/.style={%
		extra description/.append code={
			\def\length{5}
			\draw[->,blue] \pgfextra{%
				\pgfpathmoveto{#1}
				\pgfpathlineto{%
					\pgfpointadd
					{#1}
					{\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{x}}}%
				}%
			};
			\draw[->,red] \pgfextra{%
				\pgfpathmoveto{#1}%
				\pgfpathlineto{%
					\pgfpointadd
					{#1}
					{\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{y}}}%
				}%
			};
			\ifpgfplots@threedim
			\draw[->,black] \pgfextra{%
				\pgfpathmoveto{#1}%
				\pgfpathlineto{%
					\pgfpointadd
					{#1}
					{\pgfqpointscale{\length}{\pgfplotspointouternormalvectorofticklabelaxis{z}}}%
				}%
			};
			\fi
		},
	},
	/pgfplots/show outer normals/.default={%
		\ifpgfplots@threedim
			\pgfplotspointrelaxisxy{-0.03}{-0.03}%
		\else
			\pgfplotspointrelaxisxyz{-0.03}{-0.03}{-0.03}%
		\fi
	},
	/pgfplots/profiler/.code={%
		\pgfutil@ifundefined{pgfprofilenew}{%
			\usepgflibrary{profiler}%
		}{}%
		\pgfprofilenewforenvironment[all axes]{pgfplots@environment@opt}%
		\pgfprofilesetrel{all axes}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfkeys}{1}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfqkeys}{2}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysalso}{1}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysfiltered}{1}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfqkeysfiltered}{2}%
		\pgfprofilenewforcommand[pgfkeys variants]{\pgfkeysalsofiltered}{1}%
		\pgfprofilenewforcommand[pgfplotsapplistXX handling]{\pgfplotsapplistXXpushback}{1}%
		\pgfprofilenewforcommand[pgfplotsapplistXX handling]{\pgfplotsapplistXXflushbuffers}{0}%
		\pgfprofilenewforcommandpattern
				[pgfplots(app|prepend)listX handling]{\pgfplotsapplistXpushback}{##1\to##2}{{##1}\to{##2}}%
		\pgfprofilenewforcommand
				[pgfplots(app|prepend)listX handling]{\pgfplotsapplistXflushbuffers}{1}%
		\pgfprofilenewforcommandpattern
				[pgfplots(app|prepend)listX handling]{\pgfplotsprependlistXpushfront}{##1\to##2}{{##1}\to{##2}}%
		\pgfprofilenewforcommand
				[pgfplots(app|prepend)listX handling]{\pgfplotsprependlistXflushbuffers}{1}%
		\pgfprofilenewforcommand
				[pgfsys buffer]{\pgfsyssoftpath@addtocurrentpath}{1}%
		\pgfprofilenewforcommand
				[pgfsys buffer]{\pgfsyssoftpath@flushcurrentpath}{0}%
		\pgfprofilenewforcommand[math parser (basic)]{\pgfmathparse}{1}%
		\pgfprofilenewforcommand[math parser (fpu)]{\pgfmathfloatparse@}{1}%
		\pgfprofilenewforcommand[math: division (basic)]{\pgfmathdivide@}{2}%
		\pgfprofilenewforcommand[math: division (basic)]{\pgfmath@basic@divide@}{2}%
		\pgfprofilenewforcommand[near ticklabel anchors]{\pgfplots@borderanchor@for@axis}{3}%
		\pgfprofilenewforcommand[ticklabel cs]{\pgfplotspointticklabelcs}{2}%
	%	\pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodeunsigned}{1}%
	%	\pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodesignedmaplinearly}{1}%
	%	\pgfprofilenewforcommand[binary conversion]{\pgfplotsbinaryencodedimenmaplinearly}{1}%
	},%
}

% call 
%   \pgfkeyslet{.../.@cmd}\pgfplots@cant@set@in@this@context
% to replace a key with a generic error message.
\def\pgfplots@cant@set@in@this@context#1\pgfeov{\pgfplots@cant@set@in@this@context@}
\def\pgfplots@cant@set@in@this@context@{%
	\pgfplotsthrow{unsupported operation}{Sorry, you can't change `\pgfkeyscurrentkeyRAW' in this context. Maybe you need to provide it as \string\begin{axis}[\pgfkeyscurrentkeyRAW=...] ?}\pgfeov
}


{
\pgfkeysdef{/pgfplots/empty command key}{}%
\pgfkeysgetvalue{/pgfplots/empty command key/.@cmd}\pgfplots@loc@TMPa
\global\let\pgfplots@empty@command@key=\pgfplots@loc@TMPa

\pgfkeys{/empty/.style={}}%
\pgfkeysgetvalue{/empty/.@cmd}\pgfplots@loc@TMPa
\global\let\pgfplots@empty@style@key=\pgfplots@loc@TMPa
}

% Only define if it is undefined. It may be possible that related libraries
% habe been loaded before pgfplots.
\pgfkeysifdefined{/pgfplots/@backgroundpath@hook/.@cmd}{\relax}{%
	\pgfkeysdef{/pgfplots/@backgroundpath@hook}{}%
}

\def\pgfplots@cmdkey@alias#1=#2;{%
	\pgfkeysgetvalue{/pgfplots/#2/.@cmd}\pgfplots@glob@TMPa
	\pgfkeyslet{/pgfplots/#1/.@cmd}\pgfplots@glob@TMPa
}%
\pgfplots@cmdkey@alias xlabel style=x label style;
\pgfplots@cmdkey@alias ylabel style=y label style;
\pgfplots@cmdkey@alias zlabel style=z label style;
\pgfplots@cmdkey@alias xticklabel style=x tick label style;
\pgfplots@cmdkey@alias yticklabel style=y tick label style;
\pgfplots@cmdkey@alias zticklabel style=z tick label style;
\pgfplots@cmdkey@alias ticklabel style=tick label style;
%\pgfplots@cmdkey@alias xtick scale label style=x tick scale label style;
%\pgfplots@cmdkey@alias ytick scale label style=y tick scale label style;
\pgfplots@cmdkey@alias xtick style=x tick style;
\pgfplots@cmdkey@alias ytick style=y tick style;
\pgfplots@cmdkey@alias ztick style=z tick style;


% A backwards compatibility method which works as follows:
% if any user specified arguments exist for the 'domain' or 'samples
% at' or 'samples' keys, nothing is done.
%
% It these keys are empty, we switch to backwards compatibility mode
% and acquire the key settings from tikz.
%
% This allows something like
% \begin{tikzpicture}[samples=70,domain=1:5]
%   \begin{axis}
%		\addplot {x^2};
%   \end{axis}
% \end{tikzpicture}
%
%  POSTCONDITION:
%  		- \pgfplots@plot@domain = value of '/pgfplots/domain',
%  		- \pgfplots@plot@samples@at = the value of	'/pgfplots/samples at',
%  		- \pgfplots@plot@samples = value of '/pgfplots/samples',
%  	the values after any backwards compatibility issues will be used.
\def\pgfplots@validate@plot@domain@arguments{%
	\pgfkeysgetvalue{/pgfplots/samples}\pgfplots@plot@samples
	\ifx\pgfplots@plot@samples\pgfutil@empty
		\pgfplots@gettikzinternal@keyval{samples}{tikz@plot@samples}{25}%
		\pgfkeyslet{/pgfplots/samples}{\tikz@plot@samples}%
		\let\pgfplots@plot@samples=\tikz@plot@samples
		\def\pgfplots@loc@TMPa{0}% <- whether the tikz backw. compatibility shall resample
	\else
		\def\pgfplots@loc@TMPa{1}%
	\fi
	\pgfkeysgetvalue{/pgfplots/domain}\pgfplots@plot@domain
	\pgfkeysgetvalue{/pgfplots/samples at}\pgfplots@plot@samples@at
	\ifx\pgfplots@plot@domain\pgfutil@empty
		% simply acquire /tikz/domain value:
		\pgfplots@gettikzinternal@keyval{domain}{tikz@plot@domain}{-5:5}%
		\pgfkeyslet{/pgfplots/domain}{\tikz@plot@domain}%
		\let\pgfplots@plot@domain=\tikz@plot@domain
		%
		\ifx\pgfplots@plot@samples@at\pgfutil@empty
			\if 1\pgfplots@loc@TMPa
				% Resample! See above.
				\tikzset{samples=\pgfplots@plot@samples}%
			\fi
			\pgfplots@gettikzinternal@keyval{samples at}{tikz@plot@samplesat}{-5,-4.6,...,5}%
			\pgfkeyslet{/pgfplots/samples at}{\tikz@plot@samplesat}%
			\let\pgfplots@plot@samples@at=\tikz@plot@samplesat
		\else
			% routines should use \pgfplots@plot@samples@at.
		\fi
	\fi
	% do that such that any active ':' sign will be expanded - for
	% french babel support.
	\edef\pgfplots@plot@domain{\pgfplots@plot@domain}%
	\pgfkeyslet{/pgfplots/domain}\pgfplots@plot@domain
}%

\def\pgfplots@set@at#1{\def\pgfplots@at{#1}}%


% DEPRECATED
\long\def\axispreset#1{%
	\pgfplotsset{every axis/.append style={#1}}%
}
% DEPRECATED
\long\def\legendpreset#1{%
	\pgfplots@error{Sorry, legendpreset is now deprecated, along with the legend options text width and font. Legends are now TikZ-matrizes which provide better alignment and can be placed horizontally. See the manual for details.}%
}


% #1 axis (x or y)
% #2 the label
\long\def\pgfplots@show@label#1#2{%
	\begingroup
	% Prepare special alignment features here.
	%
	% The idea is to:
	% 1. Declare a local COORDINATE SYSTEM to place labels, 
	% the 'ticklabel cs' for the current axis.
	% It takes 1-2 arguments where the first is the coordinate on the
	% ticklabel axis (between 0 and 1). The second is an optional shift orthogonal to
	% the axis in direction of the outer normal. The minimum shift is
	% the largest' ticklabels dimension.
	%
	% 2. Declare a local ANCHOR to align labels, the 'near ticklabel'
	% anchor.
	%
	% Both things are not necessary - but they *can* be used.
	\tikzdeclarecoordinatesystem{ticklabel}{\pgfplotspointticklabelcs[\pgfkeysvalueof{/pgfplots/#1label shift}]{#1}{##1}}%
	\pgfplotsdeclareborderanchorforticklabelaxis{#1}{near ticklabel}%
	%
	\pgfkeysgetvalue{/tikz/sloped/.@cmd}\pgfplots@loc@TMPa
	\pgfkeyslet{/tikz/sloped/orig/.@cmd}\pgfplots@loc@TMPa
	\pgfkeysdef{/tikz/sloped}{\pgfkeysalso{/tikz/sloped like #1 axis}}%
	%
	\node 
		[/pgfplots/every axis label,%
		/pgfplots/every axis #1 label]
	{#2};
	\endgroup
}


\long\def\pgfplots@show@title#1{%
	\node%
		[/pgfplots/every axis title]
		{#1};
}


% #1: the 'a' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceA)
% #2: the 'b' axis on the orentied surface (the same as \pgfplotspointonorientedsurfaceB)
\def\pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3{%
	\if2\csname pgfplots@#1axislinesnum\endcsname
		\draw[/pgfplots/every inner #1 axis line,%
			decorate,%
			#1discont,%
			decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}]
		\pgfextra
		\csname pgfplotspointonorientedsurfaceabsetupforset#3\endcsname{\csname pgfplots@logical@ZERO@#3\endcsname}{2}%
		\pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
		\pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@logical@ZERO@#2\endcsname}}%
		\endpgfextra
		;
	\fi
}%

% Ok, we don't mind whether edges with thick lines look ugly. We just
% draw separate lines. This here is necessary if we want arrow heads.
%
% #1: the 'a' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceA)
% #2: the 'b' axis on the oriented surface (the same as \pgfplotspointonorientedsurfaceB)
\def\pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2{%
	\if2\csname pgfplots@#1axislinesnum\endcsname
		% centered axis lines handled elsewhere.
	\else
	\scope[/pgfplots/every outer #1 axis line,
		#1discont,decoration={pre length=\csname #1disstart\endcsname, post length=\csname #1disend\endcsname}]
		\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{%
			\draw decorate {
				\pgfextra
				\pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2min\endcsname}}%
				\pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2min\endcsname}}%
				\endpgfextra 
				};
		}{}%
		\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{%
			\draw decorate {
				\pgfextra
				\pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\csname pgfplots@#2max\endcsname}}%
				\pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#2max\endcsname}}%
				\endpgfextra 
				};
		}{}%
	\endscope
	\fi
}%

% This here is complicated: we try to create good edges and draw a
% SINGLE path for the partial or complete rectangle
%
%  -----
%  |   |
%  |   |
%  -----
%
%  ATTENTION: this thing is used IF AND ONLY IF  d=2 and the axis is
%  drawn as box.
\def\pgfplots@drawaxis@outerlines@cycledpath{%
	\draw[
		/pgfplots/every outer x axis line, % FIXME! these outer styles need much more attention :-(
		/pgfplots/every outer y axis line]
	% FIXME : replace this here with basic layer! This should also
	% allow closed paths:
	(\pgfplots@xmin,	\pgfplots@ymin)
\ifpgfplots@hide@y
	{ (\pgfplots@xmin,	\pgfplots@ymax) }
\else
 	\ifcase\pgfplots@yaxislinesnum
	    decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xmin,	\pgfplots@ymax) }
	\or decorate [ydiscont,decoration={pre length=\ydisstart, post length=\ydisend}] { -- (\pgfplots@xmin,	\pgfplots@ymax) }
	\or { (\pgfplots@xmin,	\pgfplots@ymax) }
	\or { (\pgfplots@xmin,	\pgfplots@ymax) }
	\fi
\fi
\ifpgfplots@hide@x
	{ (\pgfplots@xmax,	\pgfplots@ymax) }
\else
	\ifcase\pgfplots@xaxislinesnum
	    decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xmax,	\pgfplots@ymax) }
	\or { (\pgfplots@xmax,	\pgfplots@ymax) }
	\or { (\pgfplots@xmax,	\pgfplots@ymax) }
	\or decorate [xdiscont,decoration={pre length=\xdisstart, post length=\xdisend}] { -- (\pgfplots@xmax,	\pgfplots@ymax) }
	\fi
\fi
\ifpgfplots@hide@y
	{ (\pgfplots@xmax,	\pgfplots@ymin) }
\else
	\ifcase\pgfplots@yaxislinesnum
	    decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xmax,	\pgfplots@ymin) }
	\or { (\pgfplots@xmax,	\pgfplots@ymin) }
	\or { (\pgfplots@xmax,	\pgfplots@ymin) }
	\or decorate [ydiscont,decoration={pre length=\ydisend, post length=\ydisstart}] { -- (\pgfplots@xmax,	\pgfplots@ymin) }
	\fi
\fi
\ifpgfplots@hide@x
	{ (\pgfplots@xmin,	\pgfplots@ymin) }
\else
	\ifcase\pgfplots@xaxislinesnum
	    decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xmin,	\pgfplots@ymin) }
	\or decorate [xdiscont,decoration={pre length=\xdisend, post length=\xdisstart}] { -- (\pgfplots@xmin,	\pgfplots@ymin) }
	\or { (\pgfplots@xmin,	\pgfplots@ymin) }
	\or { (\pgfplots@xmin,	\pgfplots@ymin) }
	\fi% can't use cycle here!
\fi
	; %	-- cycle;
}%

% Assigns the macros
% #1disstart
% #1disend
% and the key /tikz/#1discont  for use in the axis line routines.
%
% #1 : either x or y.
\def\pgfplots@drawaxis@lines@preparediscont@for#1{%
	\ifnum\csname pgfplots@#1axisdiscontnum\endcsname>0
		\begingroup
		% this group employs several temporary dimension registers
		% and is therefor scoped:
		\let\disstart=\pgf@ya
		\let\disend=\pgf@yb
		\disend=\csname pgfplots@#1max@reg\endcsname
		\advance\disend by -\csname pgfplots@#1min@reg\endcsname
		\disend=\csname pgfplots@#1@veclength\endcsname\disend
		\ifcase\csname pgfplots@#1axisdiscontnum\endcsname\relax
			% has already been checked above.
		\or
			\def\discontstyle{decoration={zigzag,segment length=12pt, amplitude=4pt}}%
			\advance \disend by -16pt
		\or
			\def\discontstyle{decoration={ticks,segment length=4pt, amplitude=8pt}}%
			\advance \disend by -8pt
		\fi
		% if #1max + shift < 0pt  (shift is 0 without the scaling trafo)
		\ifdim\csname pgfplots@#1max@reg\endcsname<-\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname pt
			% swap start and end
			\disstart=\disend
			\disend=4pt
		\else
			\disstart=4pt
		\fi
		% carry local computations outside of group:
		\xdef\pgfplots@glob@TMPa{%
			\noexpand\def\expandafter\noexpand\csname #1disstart\endcsname{\the\disstart}%
			\noexpand\def\expandafter\noexpand\csname #1disend\endcsname{\the\disend}%
			\noexpand\pgfkeysdef{/tikz/#1discont}{\noexpand\pgfkeysalso{\discontstyle}}%
		}%
		\endgroup
		\pgfplots@glob@TMPa
	\else
		\expandafter\def\csname #1disstart\endcsname{0pt}%
		\expandafter\def\csname #1disend\endcsname{0pt}%
		\pgfkeyslet{/tikz/#1discont}=\pgfutil@empty
	\fi
}%

\def\pgfplots@rememberplotspec@for@label{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@for@label@}{\pgfplots@rememberplotspec@for@label@[]}}%
\def\pgfplots@rememberplotspec@for@label@[#1]#2{%
	\expandafter\gdef\csname pgfplots@last@plot@style@#1\endcsname{#2}%
	\global\pgfplots@has@label@informationtrue
}%
\def\pgfplots@rememberplotspec{\pgfutil@ifnextchar[{\pgfplots@rememberplotspec@opt}{\pgfplots@rememberplotspec@opt[]}}%
\def\pgfplots@rememberplotspec@opt[#1]#2{%
	\pgfplots@rememberplotspec@for@label[#1]{#2}%
	\pgfplotslistpushbackglobal{#2}\to\pgfplots@plotspeclist
}

\def\pgfplots@getautoplotspec into#1{%
	\begingroup
	\let#1=\pgfutil@empty
	\pgfkeysgetvalue{/pgfplots/cycle multi list/@dim}\pgfplots@cycle@dim
	%
	\let\pgfplots@listindex=\pgfplots@numplots
	\pgfkeysgetvalue{/pgfplots/cycle list shift}\pgfplots@listindex@shift
	\ifx\pgfplots@listindex@shift\pgfutil@empty
	\else
		\c@pgf@counta=\pgfplots@listindex\relax
		\advance\c@pgf@counta by\pgfplots@listindex@shift\relax
		\ifnum\c@pgf@counta<0
			\c@pgf@counta=-\c@pgf@counta
		\fi
		\edef\pgfplots@listindex{\the\c@pgf@counta}%
	\fi
	\ifnum\pgfplots@cycle@dim>0
		% use the 'cycle multi list' feature.
		%
		% it employs a scalar -> multiindex map like
		% void fromScalar( size_t d, size_t scalar, size_t* Iout, const size_t* N )
		% {
		% 	size_t ret=scalar;
		% 	for( int i = d-1; i>=0; --i ) {
		% 		Iout[i] = ret % N[i];
		% 		ret /= N[i];
		% 	}
		% }
		% to get the different indices into the cycle lists.
		%-------------------------------------------------- 
		\c@pgf@counta=\pgfplots@cycle@dim\relax
		\c@pgf@countb=\pgfplots@listindex\relax
		\advance\c@pgf@counta by-1
		\pgfplotsloop{%
			\ifnum\c@pgf@counta<0
				\pgfplotsloopcontinuefalse
			\else
				\pgfplotsloopcontinuetrue
			\fi
		}{%
			\pgfkeysgetvalue{/pgfplots/cycle multi list/@N\the\c@pgf@counta}\pgfplots@cycle@N
			% compute list index:
			\pgfplotsmathmodint{\c@pgf@countb}{\pgfplots@cycle@N}%
			\divide\c@pgf@countb by \pgfplots@cycle@N\relax
			%
			\expandafter\pgfplots@getautoplotspec@
				\csname pgfp@cyclist@/pgfplots/cycle multi list/@list\the\c@pgf@counta @\endcsname
				{\pgfplots@cycle@N}%
				{\pgfmathresult}%
			\t@pgfplots@toka=\expandafter{#1,}%
			\t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
			\edef#1{\the\t@pgfplots@toka\the\t@pgfplots@tokb}%
			\advance\c@pgf@counta by-1
		}%
	\else
		% normal cycle list:
		\pgfplotslistsize\autoplotspeclist\to\c@pgf@countd
		\pgfplots@getautoplotspec@{\autoplotspeclist}{\c@pgf@countd}{\pgfplots@listindex}%
		\let#1=\pgfplotsretval
	\fi
	\pgfmath@smuggleone#1%
	\endgroup
}
% #1: list name (macro!)
% #2: list size (integer register or value)
% #3: list element index
%
% defines \pgfplotsretval
\def\pgfplots@getautoplotspec@#1#2#3{%
	\ifnum#2=0
		\let\pgfplotsretval=\pgfutil@empty
	\else
		\pgfplotsmathmodint{#3}{#2}%
		\pgfplotslistselect\pgfmathresult\of#1\to\pgfplotsretval
	\fi
}


\long\def\pgfplots@path#1;{%
	\pgfplots@path@enqueue{#1;}%
}

% This thing here shall be used to replace any '\path' where \axispath
% shall be used.
\long\def\pgfplots@replacement@for@tikz@path#1;{%
	\axispath\path#1;%
}
\def\pgfplots@replacement@for@scope{\pgfutil@ifnextchar[{\pgfplots@replacement@for@scope@}{\pgfplots@replacement@for@scope@[]}}%
\def\pgfplots@replacement@for@scope@[#1]{\pgfplotsextra{\scope[#1]}}%
\def\pgfplots@replacement@for@endscope{\pgfplotsextra\endscope}%

{
	% A block which handles active semicolons.
	%
	% ATTENTION: this block does only work if
	% \pgfplots@addplotimpl.... changes are reflected here!
	%
	\catcode`\;=\active
	\globaldefs=1
	% 'AS' == 'active semicolon'
	\def\pgfplots@path@AS#1;{\pgfplots@path@enqueue{#1;}}%
	\long\def\pgfplots@replacement@for@tikz@path@AS#1;{%
		\axispath\path#1;%
	}%
	\pgfplots@appendto@activesemicolon@switcher{%
		\let\pgfplots@path=\pgfplots@path@AS
		\let\pgfplots@replacement@for@tikz@path=\pgfplots@replacement@for@tikz@path@AS
	}%
}


% Will be available as \closedcycle command inside of an axis.
%
% It closes the current plot by drawing lines to the last "zero
% level".
%
% That means the current plot is connected orthogonally with the
% x-axis, allowing fill commands.
%
% For stacked plots, \closedcycle is special (it connects with the
% previous \addplot command).
%
% Example:
% \addplot coordinates {(3,0.5) (4,2) (5,1)} \closedcycle;
\def\pgfplots@path@closed@cycle{%
	\ifpgfplots@stackedmode
		\pgfplots@stacked@path@closed@cycle
	\else
		\pgfplots@path@closed@cycle@std
	\fi
}
\def\pgfplots@path@closed@cycle@std{%
	|- (perpendicular cs: 
		vertical line through={(current plot begin)}, 
		horizontal line through={(\pgfplots@ZERO@x,\pgfplots@ZERO@y)})
	-- cycle
}%

% Remembers the plotting command #2 and '#3=plot coordinates {...} ...';
% for later postprocessing of the coordinates.
%
% #1: commands which should be executed before issueing the plotting
%        command #2 #3.
% #2:
%    the command which is responsable for drawing.
%    - If #2 is NOT '\pgfutil@empty', we expect #3 to contain only
%      EXPANDABLE DATA.
%      That's important for postponed floating point arithmetics in #3.
%    - If #2='\pgfutil@empty', we don't make any assumption about #3
%      and process it as-is.
%
% #3: see above.
%
% #4: commands which should be executed after '#2 #3'.
%
\long\def\pgfplots@path@enqueue@coords#1#2#3#4{%
	\pgfplotslistpushbackglobal{#1}{#2}{#3}{#4}\to\pgfplots@stored@plotlist
}

% this was formerly slightly different than
% \pgfplots@path@enqueue@coords, but it is now the same.
\let\pgfplots@addplot@enqueue@coords=\pgfplots@path@enqueue@coords


% Remembers the plotting command #1.
\long\def\pgfplots@path@enqueue#1{%
	\pgfplots@path@enqueue@coords{}{}{#1}{}%
}
% Use
%\begin{axis}
%	\pgfplotsextra{
%	... basic level commands or whatever...
%	}
%\end{axis}
% to process the special commands by pgfplots.
% This is the same treatment as for TikZ \path commands:
% the commands will be processed as soon as the axis is finished- not
% before.
%
% In contrast to \path, \pgfplotsextra can contain any command(s).
\let\pgfplotsextra=\pgfplots@path@enqueue


% Assigns a legend.
% Syntax:
% \legend{entry 1\\entry2\\entry3}
\def\pgfplots@command@legend{
	\pgfutil@ifnextchar[{%
		\pgfplots@error{Sorry, legend options are now deprecated. Legends are now TikZ-matrizes which provide better alignment and can be placed horizontally. See the manual for details.}%
		\pgfplots@command@legend@impl
	}{%
		\pgfplots@command@legend@impl
	}%
}

\def\pgfplots@command@legend@impl#1{%
	\pgfplots@assign@list\pgfplots@loc@TMPc{#1}%
	\global\let\pgfplots@legend=\pgfplots@loc@TMPc
}

\def\pgfplots@reverselegend{%
	% Reverse \pgfplots@plotspeclist
	\begingroup
		\pgfplotslistnewempty\pgfplots@plotspeclist@reversed
		\pgfplotslistforeachungrouped\pgfplots@plotspeclist\as\pgfplots@plotspeclisttmp{%
			\expandafter\pgfplotslistpushfront\pgfplots@plotspeclisttmp\to\pgfplots@plotspeclist@reversed
		}%
		\global\let\pgfplots@plotspeclist=\pgfplots@plotspeclist@reversed
		\let\pgfplots@legend@reversed=\relax
		%
		% Reverse \pgfplots@legend
		\pgfplotslistnewempty\pgfplots@legend@reversed
		\pgfplotslistforeachungrouped\pgfplots@legend\as\pgfplots@legendtmp{%
			\expandafter\pgfplotslistpushfront\pgfplots@legendtmp\to\pgfplots@legend@reversed
		}%
		\global\let\pgfplots@legend=\pgfplots@legend@reversed
	\endgroup
}

\def\pgfplots@transposelegend{%
	\ifnum\pgfplots@legend@columns>1
		\begingroup
		\pgfplots@transposelegend@
		\let\pgfplots@legend@columns=\c@pgfplots@row@end
		\pgfmath@smuggleone\pgfplots@legend@columns
		\endgroup
	\fi
}
\def\pgfplots@transposelegend@{%
	\let\c@pgfplots@row=\c@pgf@countb
	\let\c@pgfplots@col=\c@pgf@countc
	\let\c@pgfplots@no=\c@pgf@countd
	\c@pgfplots@row=0
	\c@pgfplots@col=0
	\c@pgfplots@no=0
	\pgfplotslistforeachungrouped\pgfplots@legend\as\entry{%
		\expandafter\let\csname m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname=\entry
		\advance\c@pgfplots@col by1
		\ifnum\pgfplots@legend@columns=\c@pgfplots@col\relax
			\c@pgfplots@col=0
			\advance\c@pgfplots@row by1
		\fi
		\advance\c@pgfplots@no by1
	}%
	\ifnum\c@pgfplots@col=0
	\else
		\advance\c@pgfplots@row by1
	\fi
	\edef\c@pgfplots@row@end{\the\c@pgfplots@row}%
	\edef\c@pgfplots@no@leg{\the\c@pgfplots@no}%
	%
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\c@pgfplots@row=0
	\c@pgfplots@col=0
	\c@pgfplots@no=0
	\pgfplotslistforeachungrouped\pgfplots@plotspeclist\as\entry{%
		\expandafter\let\csname m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname=\entry
		\advance\c@pgfplots@col by1
		\ifnum\pgfplots@legend@columns=\c@pgfplots@col\relax
			\c@pgfplots@col=0
			\advance\c@pgfplots@row by1
		\fi
		\advance\c@pgfplots@no by1
	}%
	\ifnum\c@pgfplots@col=0
	\else
		\advance\c@pgfplots@row by1
	\fi
	\ifnum\c@pgfplots@row<\c@pgfplots@row@end
		\edef\c@pgfplots@row@end{\the\c@pgfplots@row}%
	\fi
	\ifnum\c@pgfplots@no<\c@pgfplots@no@leg
		\edef\c@pgfplots@no@leg{\the\c@pgfplots@no}%
	\fi
	%
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\c@pgfplots@col=0
	\global\pgfplotslistnewempty\pgfplots@legend%
	\global\pgfplotslistnewempty\pgfplots@plotspeclist%
	\pgfplotsloop{%
		\ifnum\pgfplots@legend@columns=\c@pgfplots@col
			\pgfplotsloopcontinuefalse
		\else
			\pgfplotsloopcontinuetrue
		\fi
	}{%
		\c@pgfplots@row=0
		\pgfplotsloop{%
			\ifnum\c@pgfplots@row@end=\c@pgfplots@row
				\pgfplotsloopcontinuefalse
			\else
				\pgfplotsloopcontinuetrue
			\fi
		}{%
			\pgfutil@ifundefined{m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col}{%
			}{%
				\pgfutil@ifundefined{m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col}{%
				}{%
					\expandafter\let\expandafter\pgfplots@legendtmp\csname m@pgfplots@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname
					\expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@legendtmp}\to\pgfplots@legend%
					%
					\expandafter\let\expandafter\pgfplots@legendtmp\csname m@pgfplots@img@\the\c@pgfplots@row,\the\c@pgfplots@col\endcsname
					\expandafter\pgfplotslistpushbackglobal\expandafter{\pgfplots@legendtmp}\to\pgfplots@plotspeclist%
				}%
			}%
			\advance\c@pgfplots@row by1
		}%
		\advance\c@pgfplots@col by1
	}%
}%


\def\pgfplots@addlegendentryexpanded{%
	\pgfutil@ifnextchar[{%
		\pgfplots@addlegendentryexpanded@opts
	}{%
		\pgfplots@addlegendentryexpanded@opts[]%
	}%
}
\long\def\pgfplots@addlegendentryexpanded@opts[#1]#2{%
	\begingroup
		\let\protect=\noexpand
		\long\edef\pgfplots@loc@TMPa{#2}%
		\def\pgfplots@loc@TMPb{\pgfplots@addlegendentry@opts[#1]}%
		\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
	\endgroup
}%

\def\pgfplots@addlegendimage{\pgfutil@ifnextchar[{\pgfplots@addlegendimage@opt}{\pgfplots@addlegendimage@opt[]}}%
\def\pgfplots@addlegendimage@opt[#1]#2{%
	\pgfplots@rememberplotspec[#1]{/pgfplots/every axis plot,#2,/pgfplots/.cd,/pgfplots/every axis plot post}%
}%

% This implements \addlegendentry
\def\pgfplots@addlegendentry{%
	\pgfutil@ifnextchar[{%
		\pgfplots@addlegendentry@opts
	}{%
		\pgfplots@addlegendentry@opts[]%
	}%
}
\long\def\pgfplots@addlegendentry@opts[#1]#2{%
	\pgfplotslistpushbackglobal[#1]#2\to\pgfplots@legend
}

\def\pgfplots@pop@next@legend{{%
	\globaldefs=1
	\pgfplotslistcheckempty\pgfplots@plotspeclist
	\ifpgfplotslistempty
		\let\pgfplots@curplotlist=\relax
	\else
		\pgfplotslistpopfront\pgfplots@plotspeclist\to\pgfplots@curplotlist
		\pgfplotslistcheckempty\pgfplots@legend
		\ifpgfplotslistempty
			\let\pgfplots@curlegend=\pgfutil@empty
		\else
			\pgfplotslistpopfront\pgfplots@legend\to\pgfplots@curlegend
		\fi
	\fi
	%
}}

\def\pgfplots@try@mirror@plot@handler{%
	\pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
	% this method assigns '\tikz@plot@handler'.
	% That's ok and does not introduce incompatibilities.
	\ifx\pgfplots@basiclevel@plothandler\pgfplothandlerconstantlineto
		\let\tikz@plot@handler=\pgfplothandlerconstantlinetomarkright
	\else
		\ifx\pgfplots@basiclevel@plothandler\pgfplothandlerconstantlinetomarkright
			\let\tikz@plot@handler=\pgfplothandlerconstantlineto
		\fi
	\fi
}

% #1: DEPRECATED. Unused.
% #2: plot style
\long\def\pgfplots@show@small@legendplots#1#2{%
	\begingroup
	\pgfplots@define@currentplotstyle@as{#1,#2}%
	\scope[/tikz/current plot style,/pgfplots/every legend image post]% this scoping construction allows plot styles to change 'legend image code'.
		\pgfkeysvalueof{/pgfplots/legend image code/.@cmd}\pgfeov
	\endscope
	\endgroup
	%\pgfkeysvalueof{/pgfplots/legend image code/.@cmd}{/pgfplots/.cd,#1,#2}\pgfeov
}

\def\pgfplots@split@opts{%
	\pgfutil@ifnextchar[{%
		\pgfplots@split@opts@opts
	}{%
		\pgfplots@split@opts@opts[]%
	}%
}
\long\def\pgfplots@split@opts@opts[#1]#2\pgfplots@result@to#3#4{%
	\long\def#3{#2}%
	\long\def#4{#1}%
}

% Typesets a legend node.
%
% It will either typeset a previously computed legend (which needs to be
% stored in the macro \pgfplots@already@computed@legend@node)
%
% or it creates a legend, stores the commands into the macro named
% above and typesets it.
\def\pgfplots@createlegend{%
	\pgfkeysgetvalue{/pgfplots/legend to name}\pgfplots@createlegend@toname
	\ifx\pgfplots@already@computed@legend@node\pgfutil@empty
		\pgfplotslistcheckempty\pgfplots@legend
		\ifpgfplotslistempty
			% No legend commands appeared in the document. So,
			% consider the key:
			\pgfkeysgetvalue{/pgfplots/legend entries}\pgfplots@legend
			\expandafter\pgfplots@assign@list\expandafter\pgfplots@legend\expandafter{\pgfplots@legend}%
			\pgfplotslistcheckempty\pgfplots@legend
		\fi
		\ifpgfplotslistempty
		\else
		\ifpgfplots@reverse@legend
			\pgfplots@reverselegend
		\fi
		\ifpgfplots@transpose@legend
			\pgfplots@transposelegend
		\fi
		%
		% 
		\begingroup
			\ifx\pgfplots@createlegend@toname\pgfutil@empty
				% ok, draw legend.
				\def\pgfplots@createlegend@prepareimage@to##1{%
					\t@pgfplots@tokc=\expandafter{\pgfplots@curplotlist}%
					\edef##1{\noexpand\pgfplots@show@small@legendplots{}{\the\t@pgfplots@tokc}}%
				}%
			\else
				% export legend instead of drawing it.
				\def\pgfplots@createlegend@prepareimage@to##1{%
					\t@pgfplots@tokc=\expandafter{\pgfplots@curplotlist}%
					\edef\pgfplots@loc@TMPa{\noexpand\pgfplots@export@legend@image@to@macro{\the\t@pgfplots@tokc}{}}%
					\pgfplots@loc@TMPa
					\let##1=\pgfplotsretval
				}%
			\fi
			% assemble a 
			% \matrix {
			% 	small plot  & legend1\\
			% 	small plot  & legend2\\
			% 	...
			% };
			% command [and using the 'legend columns' option]
			%
			% \t@pgfplots@toka={
			% 	small plot  & legend1\\
			% 	small plot  & legend2\\
			% 	...
			% }
			% ( I have allocated the token registers in my
			% liststructure.sty)
			% 
			% \global\def\pgfplots@glob@TMPa{
			% 	\matrix {
			% 		\TOKL@TA
			% 	};
			% }
			% -> finally, \pgfplots@glob@TMPa will contain the complete command.
			\t@pgfplots@toka={}%
			\let\curcolumnNum=\c@pgf@counta
			\let\maxcolumnCount=\c@pgf@countb
			\let\legendplotpos=\c@pgf@countc
			\legendplotpos\expandafter=\pgfplots@legend@plot@pos
			\curcolumnNum=0
			\maxcolumnCount=\pgfplots@legend@columns\relax
			%
			\pgfplotsloop{%
				\pgfplots@pop@next@legend
				\ifpgfplotslistempty
					\pgfplotsloopcontinuefalse
				\else
					\pgfplotsloopcontinuetrue
				\fi
			}{%
				\ifx\pgfplots@curlegend\pgfutil@empty
				\else
					\advance\curcolumnNum by1
					\begingroup
					% \pgfplots@curlegend@opts are any options for
					% this single legend text, provided as
					% \addlegendentry[<options>]{<text>}
					% or
					% legend entries={...,[<options>]<text>, ....}
					\expandafter\pgfplots@split@opts\pgfplots@curlegend\pgfplots@result@to{\pgfplots@curlegend}{\pgfplots@curlegend@opts}%
					\pgfplots@createlegend@prepareimage@to{\pgfplotsretval}%
					%
					\t@pgfplots@tokb=\expandafter{\pgfplots@curlegend@opts}%
					\t@pgfplots@tokc=\expandafter{\pgfplots@curlegend}%
					%
					% prepare the \node[<options>] {<text>} into \t@pgfplots@tokc
					\edef\pgfplots@loc@TMPa{\noexpand\node[\the\t@pgfplots@tokb]{\the\t@pgfplots@tokc};}%
					\t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}%
					%
					% and the legend image into \t@pgfplots@tokb:
					\t@pgfplots@tokb=\expandafter{\pgfplotsretval}%
					% ok. Now, the 
					% - 'b' register contains the IMAGE and
					% - 'c' register contains the TEXT
					\ifcase\legendplotpos
						% legend plot pos=left 
						\edef\pgfplots@matrixentry{%
							\the\t@pgfplots@tokb
							\noexpand\pgfmatrixnextcell
							\the\t@pgfplots@tokc%
						}%
					\or
						% legend plot pos=right
						\edef\pgfplots@matrixentry{%
							\the\t@pgfplots@tokc%
							\noexpand\pgfmatrixnextcell
							\the\t@pgfplots@tokb
						}%
					\or
						% legend plot pos=none
						\edef\pgfplots@matrixentry{%
							\the\t@pgfplots@tokc%
						}%
					\fi
					% copy it back to 'b' register:
					\t@pgfplots@tokb=\expandafter{\pgfplots@matrixentry}%
					%
					\ifnum\curcolumnNum=\maxcolumnCount
						\t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}%
					\else
						\pgfplotslistcheckempty\pgfplots@legend
						\ifpgfplotslistempty
						\else
							\pgfplotslistcheckempty\pgfplots@plotspeclist
						\fi
						\ifpgfplotslistempty
							% Ok, either the legend list is empty or
							% there are no more plot specifications.
							%
							% Finalize matrix:
							\t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\\}%
						\else
							\t@pgfplots@tokb=\expandafter{\the\t@pgfplots@tokb\pgfmatrixnextcell}%
						\fi
					\fi
					\xdef\pgfplots@glob@TMPa{%
						\the\t@pgfplots@toka
						\the\t@pgfplots@tokb
					}%
					\endgroup
					\ifnum\curcolumnNum=\maxcolumnCount
						\curcolumnNum=0
					\fi
					\expandafter\t@pgfplots@toka\expandafter{\pgfplots@glob@TMPa}%
				\fi
			}%
			\t@pgfplots@tokb={\matrix[/pgfplots/every axis legend]}%
			\xdef\pgfplots@glob@TMPa{%
				\noexpand\def\noexpand\plotnum{0}%
				\noexpand\def\noexpand\plotnumofactualtype{0}%
				\the\t@pgfplots@tokb {%
					\the\t@pgfplots@toka
				};%
			}%
		\endgroup
		\let\pgfplots@already@computed@legend@node=\pgfplots@glob@TMPa
		\fi
	\fi
%\pgfplots@message{Vor legende: \meaning\pgfplots@already@computed@legend@node^^J}%
	\ifx\pgfplots@createlegend@toname\pgfutil@empty
		% DRAW:
		\pgfplots@already@computed@legend@node
	\else
		% apply the 'legend to name' feature:
		%
		% store legend contents:
		%
		\t@pgfplots@toka=\expandafter{\pgfplots@already@computed@legend@node}%
		\pgfkeysgetvalue{/pgfplots/every axis legend/.@cmd}\pgfplots@loc@TMPa
		\t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa\pgfeov}%
		%
		\pgfplots@assemble@ref@picture
			{\pgfplots@legend@to@name}
			{\tikz[/pgfplots/every legend to name picture/.try]{\pgfplots@legend@to@name}}%
		\t@pgfplots@tokc=\expandafter{\pgfplotsretval}%
		%
		\expandafter\xdef\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\endcsname{%
			\noexpand\begingroup
			\noexpand\def\noexpand\pgfplots@legend@to@name{%
				\noexpand\pgfkeysdef{/pgfplots/every axis legend}{\the\t@pgfplots@tokb}%
				\noexpand\def\noexpand\numplots{\numplots}%
				\the\t@pgfplots@toka
			}%
			\the\t@pgfplots@tokc
			\noexpand\endgroup
		}%
		\t@pgfplots@toka=\expandafter\expandafter\expandafter{\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\endcsname}%
		\pgfplots@auxwrite{%
			\noexpand\expandafter
			\noexpand\gdef
				\noexpand\csname pgfplots@legend@to@name@\pgfplots@createlegend@toname\noexpand\endcsname%
					{\the\t@pgfplots@toka}%
		}%
		\begingroup
		%
		% make sure \ref{<legendname>} works:
		\pgfplots@label{\pgfplots@createlegend@toname}{pgfplots@legend@to@name@}%
		\endgroup
	\fi
}

% Defines a new \label{#1}. When \ref{#1} is used, the code 
% \csname #2#1\endcsname
% will be invoked.
\def\pgfplots@label#1#2{%
	\begingroup
	\edef\@currentlabel{%
		\string\expandafter
		\string\protect
		\string\csname\space #2#1\string\endcsname
	}%
	\pgfutil@ifundefined{hyper@makecurrent}{}{%
		\hyper@makecurrent{pgfplotslink}%
		\hyper@anchorstart{\@currentHref}{}\hyper@anchorend
		\pgfplotsutil@advancestringcounter@global\c@pgfplots@label
	}%
	\expandafter\label\expandafter{#1}%
	\endgroup
}%
\gdef\c@pgfplots@label{0}%
\def\theHpgfplotslink{\theHsection.\c@pgfplots@label}%

% this is deprecated. Use \ref{#1} instead.
\def\pgfplotslegendfromname#1{%
	\pgfplots@texdist@protect\pgfplotslegendfromname@{#1}%
}%
\def\pgfplotslegendfromname@#1{%
	\pgfutil@ifundefined{pgfplots@legend@to@name@#1}{%
		\pgfutil@ifundefined{ref}{%
			\pgfplots@warning{There is no `legend to name=#1', sorry. I am skipping it}%
			\string\pgfplotslegendfromname{#1}: ??%
		}{%
			\ref{\string\pgfplotslegendfromname{#1}}%
		}%
	}{%
		\csname pgfplots@legend@to@name@#1\endcsname
	}%
}%
% this is deprecated. Use \ref{#1} instead.
\def\pgfplotscolorbarfromname#1{%
	\pgfplots@texdist@protect\pgfplotscolorbarfromname@{#1}%
}%
\def\pgfplotscolorbarfromname@#1{%
	\pgfutil@ifundefined{pgfplots@colorbar@to@name@#1}{%
		\pgfutil@ifundefined{ref}{%
			\pgfplots@warning{There is no `colorbar to name=#1', sorry. I am skipping it}%
			\string\pgfplotscolorbarfromname{#1}: ??%
		}{%
			\ref{\string\pgfplotscolorbarfromname{#1}}%
		}%
	}{%
		\csname pgfplots@colorbar@to@name@#1\endcsname
	}%
}%

\def\pgfplots@ifintikzpicture#1#2{%
	\pgfutil@ifundefined{filldraw}{#2}{#1}%
}%

% DEPRECATED.
\def\skipsuffixzero#1.#2|{
	{%
	\def\pgfplots@loc@TMPa{#2}%
	\def\pgfplots@loc@TMPb{0}%
	\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
		\global\def\pgfmathresult{#1}%
	\else
		\global\def\pgfmathresult{#1.#2}%
	\fi
	}%
}

\def\pgfmathlogtologten#1{%
	\pgfmathparse{#1}%
	\expandafter\pgfmathlogtologten@\expandafter{\pgfmathresult}%
}

% Simply divides #1 by log(10).
\def\pgfmathlogtologten@#1{%
	\pgfmathmultiply@{#1}\reciproclogten%
}%

% DEPRECATED.
\def\logtologtentomacro#1#2{%
	\pgfmathlogtologten@{#1}%
	\expandafter\skipsuffixzero\pgfmathresult|%
	\let#2=\pgfmathresult
}

% DEPRECATED.
\def\logtologten#1{%
	\pgfmathlogtologten@{#1}%
	\expandafter\skipsuffixzero\pgfmathresult|%
	\pgfmathresult
}

\pgfkeysdef{/pgfplots/@enlargelimits/true}{%
	\def\bool@pgfplots@loc@enlargelimits@min{1}%
	\def\bool@pgfplots@loc@enlargelimits@max{1}%
}%
\pgfkeysdef{/pgfplots/@enlargelimits/false}{%
	\def\bool@pgfplots@loc@enlargelimits@min{0}%
	\def\bool@pgfplots@loc@enlargelimits@max{0}%
}%
\pgfkeysdef{/pgfplots/@enlargelimits/upper}{%
	\def\bool@pgfplots@loc@enlargelimits@min{0}%
	\def\bool@pgfplots@loc@enlargelimits@max{1}%
}%
\pgfkeysdef{/pgfplots/@enlargelimits/lower}{%
	\def\bool@pgfplots@loc@enlargelimits@min{1}%
	\def\bool@pgfplots@loc@enlargelimits@max{0}%
}%
\pgfkeysdef{/pgfplots/@enlargelimits/auto}{%
	\def\bool@pgfplots@loc@enlargelimits@min{0}%
	\def\bool@pgfplots@loc@enlargelimits@max{0}%
	\def\pgfplots@loc@TMPa{0}%
	\ifpgfplots@threedim
		\if\pgfplots@enlargelimits@curaxis z%
			\def\pgfplots@loc@TMPa{1}%
		\fi
	\else
		\def\pgfplots@loc@TMPa{1}%
	\fi
	\if1\pgfplots@loc@TMPa
		\pgfplots@if{pgfplots@autocompute@\pgfplots@enlargelimits@curaxis min}{%
			\def\bool@pgfplots@loc@enlargelimits@min{1}%
		}{}%
		\pgfplots@if{pgfplots@autocompute@\pgfplots@enlargelimits@curaxis max}{%
			\def\bool@pgfplots@loc@enlargelimits@max{1}%
		}{}%
	\fi
}%
\pgfkeysdef{/pgfplots/@enlargelimits/value}{%
	\pgfmathparse{#1}%
	\let\pgfplots@enlargelimits@relthresh=\pgfmathresult
	\let\pgfplots@enlargelimits@absthresh=\pgfutil@empty
}%
\pgfkeysdef{/pgfplots/@enlargelimits/rel}{\pgfkeysalso{true,value={#1}}}%
\pgfkeysdef{/pgfplots/@enlargelimits/abs value}{%
	\begingroup
	\pgfutil@namelet{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis}{pgfplots@datascaletrafo@\pgfplots@enlargelimits@curaxis @noshift}%
	\expandafter\csname pgfplotstransformcoordinate\pgfplots@enlargelimits@curaxis\endcsname{#1}%
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
	\let\pgfplots@enlargelimits@absthresh=\pgfmathresult
	\let\pgfplots@enlargelimits@relthresh=\pgfutil@empty
}%
\pgfkeysdef{/pgfplots/@enlargelimits/abs}{\pgfkeysalso{true,abs value={#1}}}%
\pgfkeysdef{/pgfplots/@enlargelimits/.unknown}{\pgfkeysalso{true,value={\pgfkeyscurrentname}}}%

\def\pgfplots@enlarge@limit@ifconfigured#1{%
	\begingroup
	\def\bool@pgfplots@loc@enlargelimits@min{0}%
	\def\bool@pgfplots@loc@enlargelimits@max{0}%
	\def\pgfplots@enlargelimits@relthresh{0.1}% the default
	\let\pgfplots@enlargelimits@absthresh=\pgfutil@empty
	\def\pgfplots@enlargelimits@curaxis{#1}%
	%
	\pgfkeysgetvalue{/pgfplots/enlarge #1 limits}{\pgfplots@loc@TMPa}%
	\def\pgfplots@loc@TMPb{\pgfqkeys{/pgfplots/@enlargelimits}}% set the argument keys
	\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
	%
	\def\bool@pgfplots@loc@enlargeany{0}%
	\if1\bool@pgfplots@loc@enlargelimits@min
		\def\bool@pgfplots@loc@enlargeany{1}%
	\else
		\if1\bool@pgfplots@loc@enlargelimits@max
			\def\bool@pgfplots@loc@enlargeany{1}%
		\fi
	\fi
	\if1\bool@pgfplots@loc@enlargeany
		\pgfplots@enlarge@limit@for{#1}%
	\fi
	\global\let\pgfplots@glob@TMPa=\bool@pgfplots@loc@enlargeany
	% assignments are made globally.
	\endgroup
	\if1\pgfplots@glob@TMPa
		\pgfplots@visphase@notify@changeofcanvaslimits{#1}%
	\fi
}

% Helper method inside of \pgfplots@enlarge@limit@ifconfigured.
%
% It modifies '#1min' and '#1max' (globally!) according to the already prepared
% booleans.
\def\pgfplots@enlarge@limit@for#1{%
	\begingroup
	\expandafter\let\expandafter\pgfplots@@min\csname pgfplots@#1min\endcsname
	\expandafter\let\expandafter\pgfplots@@max\csname pgfplots@#1max\endcsname
	\ifx\pgfplots@enlargelimits@relthresh\pgfutil@empty
		% we have an absolute enlarge value:
		\let\enlargeabsolute=\pgfplots@enlargelimits@absthresh
		\pgf@xb=\pgfplots@enlargelimits@absthresh pt
	\else
		% we have a relative enlarge value:
		\pgfmathsubtract@\pgfplots@@max\pgfplots@@min%
		\pgf@xa=\pgfmathresult pt
		\pgf@xb=\pgfplots@enlargelimits@relthresh\pgf@xa
		\edef\enlargeabsolute{\pgf@sys@tonumber{\pgf@xb}}%
	\fi
	\ifdim\pgf@xb>0.001pt
		% the case with 
		%   enlargeabsolute ~= 0
		% means that \pgfplots@@min ~= \pgfplots@@max.
		% It is handled in another method.
		%
		\if1\bool@pgfplots@loc@enlargelimits@min
			\pgfmathsubtract@\pgfplots@@min\enlargeabsolute%
			\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
		\fi
		\if1\bool@pgfplots@loc@enlargelimits@max
			\pgfmathadd@\pgfplots@@max\enlargeabsolute%
			\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
		\fi
	\fi
	\endgroup
}


% helper for \pgfplots@check@and@apply@datatrafo@for.
\def\pgfplots@compute@number@order@for@trafo@isdimen#1\tocount#2{%
	\edef\pgfplots@loc@TMPa{\pgf@sys@tonumber{#1}}%
	\pgfmathfloatparsenumber{\pgfplots@loc@TMPa}%
	\expandafter\pgfmathfloat@decompose@E\pgfmathresult\relax#2
	\advance#2 by1\relax
}

% helper for \pgfplots@check@and@apply@datatrafo@for.
% 
\def\pgfplots@compute@number@order@for@trafo@isfloat#1\tocount#2{%
	\expandafter\pgfmathfloat@decompose@E#1\relax#2\relax
	\advance#2 by1\relax
}

% Initialises the data scale transformation and applies it to any
% user specified options.
%
% PRECONDITION:
%   - all axis limits are available in float representation
%   - \pgfplots@set@default@size@options has been called before
% POSTCONDITION:
%   - the scaling transformation is set up,
%   - all axis limits are transformed,
%   - any user input (like ticks and tick labels)
%     EXCEPT unit vectors will reflect the changes.
%
% Unit vectors will be scaled later.
\def\pgfplots@check@and@apply@datatrafo@for#1{%
	\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
		\pgfplots@letcsname pgfplots@#1min@unscaled@as@float={pgfplots@#1min}%
		\pgfplots@letcsname pgfplots@#1max@unscaled@as@float={pgfplots@#1max}%
		% initialise data scale transformation 
		%   T(x) = 10^{q-m} * x
		%
		\begingroup
			\let\data@max@order=\c@pgf@counta
			\let\data@cur@order=\c@pgf@countb
			\let\data@dimen=\pgf@xa
			\let\data@tmp=\pgf@xb
			\let\data@dimen@order=\c@pgf@countc
			\let\data@EXPONENT=\c@pgf@countd
			\expandafter\let\expandafter\pgfplots@display@min@float\csname pgfplots@#1min\endcsname
			\expandafter\let\expandafter\pgfplots@display@max@float\csname pgfplots@#1max\endcsname
			\expandafter\let\expandafter\pgfplots@data@min@float\csname pgfplots@data@#1min\endcsname
			\expandafter\let\expandafter\pgfplots@data@max@float\csname pgfplots@data@#1max\endcsname
			\expandafter\let\expandafter\pgfplots@actual@trafo\csname pgfplots@datascaletrafo@#1\endcsname
			\ifpgfplots@autocompute@all@limits
			\else
				\pgfplotsmathfloatmax{\pgfplots@display@max@float}{\pgfplots@data@max@float}%
				\let\pgfplots@data@max@float=\pgfmathresult
				\pgfplotsmathfloatmin{\pgfplots@display@min@float}{\pgfplots@data@min@float}%
				\let\pgfplots@data@min@float=\pgfmathresult
			\fi
			%
			% Step 1: compute 'm', the data order
			\pgfplots@compute@number@order@for@trafo@isfloat
				\pgfplots@data@min@float
				\tocount\data@cur@order
			%
			\data@max@order=\data@cur@order
			%
			\pgfplots@compute@number@order@for@trafo@isfloat
				\pgfplots@data@max@float
				\tocount\data@cur@order
			%
			\ifnum\data@cur@order>\data@max@order
				\data@max@order=\data@cur@order
			\fi
			%
			% Step 2: compute 'q', the #1-size of the axis.
			\expandafter\ifx\csname pgfplots@#1\endcsname\pgfutil@empty
				% We have 'width' or 'height'.
				%
				% Use the order of these parameters.
				\def\pgfplots@loc@TMPa{#1}%
				\def\pgfplots@loc@TMPb{x}%
				\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
					\data@dimen=\pgfplots@width\relax
				\else
					\def\pgfplots@loc@TMPb{y}%
					\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
						\data@dimen=\pgfplots@height\relax
					\fi
				\fi
				\pgfplots@compute@number@order@for@trafo@isdimen
					\data@dimen
					\tocount\data@dimen@order
				% This here is to avoid inaccuracies in the final
				% axis rectangle size, see \pgfplots@initsizes:
				%\advance\data@dimen@order by-1
			\else
				% FIXME:
				% we have either the 'x=1cm' or 'y=1cm' option!
				% How should I initialise the trafo!?
				\data@dimen@order=3
			\fi
			%
%\message{Direction #1: data max order=\the\data@max@order;  data dimen order=\the\data@dimen@order. }%
			\data@EXPONENT=\data@dimen@order
			\advance\data@EXPONENT by-\data@max@order
			% Now, I introduce a loop which shall avoid cancellation of
			% significant digits.
			%
			% Harmless Example: 
			%  if we have data shift = -3 and 
			%  max = 2e6, min = 1e6, then max-min = 1e6; T(max)-T(min) = 1e3 which is ok.
			%  In this case, the loop won't change anything.
			%
			% Critical Example:
			%  if we have data shift = -3 and
			%  max = 1980, min = 1930 then 
			%    T(max) = 1.98 and T(min) = 1.93
			%  and thus T(max)-T(min) = 0.05 . 
			%  Considering that this is the axis range
			%  in which tick labels and plot points need to be computed, we
			%  only have two or three digits left! That happens because the
			%  prefix '19' is common and is cancelled in the subtraction.
			%  Idea: while T(max)-T(min) < O(10^2) -> increase shift by +1
			%  (and make sure that T(max) < MAX_VALID_TEX_NUMBER).
			%
			\pgfplots@loop@CONTINUEtrue
			\expandafter\edef\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}%
			\pgfutil@loop
			\expandafter\edef\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname{\the\data@EXPONENT}%
			\pgfplots@actual@trafo{\pgfplots@data@min@float}%
			\let\pgfplots@min@fixed=\pgfmathresult
			\ifpgfplots@loop@CONTINUE
				\pgfplots@actual@trafo{\pgfplots@data@max@float}%
				\let\pgfplots@max@fixed=\pgfmathresult
				\expandafter\data@tmp\pgfplots@max@fixed pt
%\message{Current trafo EXPONENT for #1 direction: \the\data@EXPONENT; original #1 data limits: [\pgfplots@data@min@float:\pgfplots@data@max@float]; current transformed #1 limits: [\pgfplots@min@fixed:\pgfplots@max@fixed]; cancellation check max-min running...}%
				\ifdim\data@tmp<0pt
					% I need absolute values here:
					\multiply\data@tmp by-1\relax
				\fi
				\pgfmathsubtract@{\pgfplots@max@fixed}{\pgfplots@min@fixed}%
				\expandafter\data@dimen\pgfmathresult pt
				\pgfplots@loop@CONTINUEfalse
				\ifdim\data@tmp<1500pt % a multiplication with '10' results in max = 15000 which is the upper limit.
					\ifdim\data@dimen<100pt % I guess if max-min = O(100), we have quite good accuracy
						\ifdim\data@dimen<0.0001pt
						\else
							\advance\data@EXPONENT by1
							\pgfplots@loop@CONTINUEtrue
						\fi
					\fi
				\fi
				%--------------------------------------------------
				% \ifdim\data@dimen>1200pt% FIXME : is this here ok!? CHECK IT!
				% 	\ifdim\data@dimen>7999pt
				% 		\advance\data@EXPONENT by-2
				% 	\else
				% 		\advance\data@EXPONENT by-1
				% 	\fi
				% 	\pgfplots@loop@CONTINUEfalse
				% \fi
				%-------------------------------------------------- 
			\pgfutil@repeat
			\xdef\pgfplots@glob@TMPa{\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname}%
			\xdef\pgfplots@glob@TMPb{\pgfplots@min@fixed}%
		\endgroup
%\message{Initialising the data scale transformation in direction #1 to 10^\pgfplots@glob@TMPa*#1 - \pgfplots@glob@TMPb...}%
		% COMPLETE INITIALISATION:
		\ifpgfplots@disabledatascaling
			% this here is a waste of time, I know it. One could really
			% safe a lot of CPU time when disabledatascaling is enabled...
			% but it requires so much extra cases; I really don't want
			% that!
			\gdef\pgfplots@glob@TMPa{0}%
			\gdef\pgfplots@glob@TMPb{0}%
		\fi
		\expandafter\let\csname pgfplots@data@scale@trafo@EXPONENT@#1\endcsname\pgfplots@glob@TMPa
		\expandafter\let\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname\pgfplots@glob@TMPb%
		%
		% ... and apply transformation to any user input
		%
		% Transform axis limits:
%\message{#1- display limits BEFORE data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}%
		\expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1min\endcsname}%
		\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
		%
		\expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1max\endcsname}%
		\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
%\message{#1- display limits after data transformation: [\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname]}%
		% Transform tick limits (if they are set):
%\message{#1- display tick limits BEFORE data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}%
		\expandafter\ifx\csname pgfplots@#1tickmin\endcsname\pgfutil@empty
		\else
			\expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmin\endcsname}%
			\expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult
		\fi
		%
		\expandafter\ifx\csname pgfplots@#1tickmax\endcsname\pgfutil@empty
		\else
			\expandafter\expandafter\csname pgfplots@datascaletrafo@#1\endcsname\expandafter{\csname pgfplots@#1tickmax\endcsname}%
			\expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
		\fi
%\message{#1- display tick limits after data transformation: [\csname pgfplots@#1tickmin\endcsname:\csname pgfplots@#1tickmax\endcsname]}%
		%
		% Convert any user-specified ticks:
		\edef\pgfplots@loc@TMPa{\csname pgfplots@#1tick\endcsname}%
		% this here should also work with 'xtick=\pgfutil@empty', the "No tick" command.
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\t@pgfplots@tokc=\expandafter{\csname pgfplots@datascaletrafo@#1\endcsname}%
			\def\pgfplots@loc@TMPb{data}%
			\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				% we have #1tick = data
				%
				% Since we have entered this method, we know that these
				% coordinate ARE ALREADY in floating point representation.
				\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname
				\expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}%
				\t@pgfplots@toka=\expandafter{\pgfplotsretval}%
				\edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}%
				\expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc
				% clear structure:
				\expandafter\global\expandafter\let\csname pgfplots@firstplot@coords@#1\endcsname=\pgfutil@empty
			\else
				\t@pgfplots@toka=\expandafter{\pgfplots@loc@TMPa}%
%\message{Converting #1tick='\csname pgfplots@#1tick\endcsname'}%
				\edef\pgfplots@loc@TMPa{{\the\t@pgfplots@toka}\the\t@pgfplots@tokc}%
				\expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc
			\fi
			\expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@loc@TMPc
		\fi
		%
		% Convert any extra-ticks, see above.
		\edef\pgfplots@loc@TMPa{\csname pgfplots@extra@#1tick\endcsname}%
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\t@pgfplots@tokc=\expandafter{\csname pgfplots@datascaletrafo@#1\endcsname}%
			\edef\pgfplots@loc@TMPa{{\csname pgfplots@extra@#1tick\endcsname}\the\t@pgfplots@tokc}%
			\expandafter\pgfplots@apply@data@scale@trafo@to@user@ticks\pgfplots@loc@TMPa\to\pgfplots@loc@TMPc
			\expandafter\let\csname pgfplots@extra@#1tick\endcsname=\pgfplots@loc@TMPc
		\fi
		%
		% Transform any explicit axis unit scalings:
		% WILL BE DONE LATER!
	}{%
		% case apply trafo == false:
		\expandafter\def\csname pgfplots@data@scale@trafo@SHIFT@#1\endcsname{0}%
		\def\pgfplots@loc@TMPb{data}%
		\expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfplots@loc@TMPb
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@firstplot@coords@#1\endcsname
			\expandafter\pgfplotsutil@unify@short@csv@list\expandafter{\pgfplots@loc@TMPa}%
			\expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplotsretval%
			% clear structure:
			\expandafter\global\expandafter\let\csname pgfplots@firstplot@coords@#1\endcsname=\pgfutil@empty
		\fi
		\expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfutil@empty
		\expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfutil@empty
	}%
}

\newif\ifpgfplots@determinedefaultvalues@isuniform
\newif\ifpgfplots@determinedefaultvalues@needs@check@uniformtick
\newif\ifpgfplots@limits@are@computed

\def\pgfplots@handle@invalid@range{%
	% COMPLETELY EMPTY AXIS:
	\pgfplots@warning{You have an axis with empty range. Replacing it with a default range and clearing all plots.}%
	\ifpgfplots@xislinear
		\pgfmathfloatcreate{0}{0.0}{0}%
		\global\let\pgfplots@xmin=\pgfmathresult
		\pgfmathfloatcreate{1}{1.0}{0}%
		\global\let\pgfplots@xmax=\pgfmathresult
		\global\let\pgfplots@data@xmin=\pgfplots@xmin
		\global\let\pgfplots@data@xmax=\pgfplots@xmax
	\else
		\gdef\pgfplots@xmin{0}%
		\gdef\pgfplots@xmax{1}%
	\fi
	\ifpgfplots@yislinear
		\pgfmathfloatcreate{0}{0.0}{0}%
		\global\let\pgfplots@ymin=\pgfmathresult
		\pgfmathfloatcreate{1}{1.0}{0}%
		\global\let\pgfplots@ymax=\pgfmathresult
		\global\let\pgfplots@data@ymin=\pgfplots@ymin
		\global\let\pgfplots@data@ymax=\pgfplots@ymax
	\else
		\gdef\pgfplots@ymin{0}%
		\gdef\pgfplots@ymax{1}%
	\fi
	\pgfplots@threedimfalse
	\def\pgfplots@xtick{}%
	\def\pgfplots@ytick{}%
	\def\pgfplots@extra@xtick{}%
	\def\pgfplots@extra@ytick{}%
	\def\pgfplots@xtickten{}%
	\def\pgfplots@ytickten{}%
	% clear all plots!
	\pgfplots@init@cleared@structures
}
\def\pgfplots@check@invalid@range{%
	\pgfplots@limits@are@computedtrue
	\ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
		\pgfplots@limits@are@computedfalse
	\fi
	\ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
		\pgfplots@limits@are@computedfalse
	\fi
	\ifx\pgfplots@ymin\pgfplots@invalidrange@ymin
		\pgfplots@limits@are@computedfalse
	\fi
	\ifx\pgfplots@ymax\pgfplots@invalidrange@ymax
		\pgfplots@limits@are@computedfalse
	\fi
	\ifpgfplots@threedim
		\ifx\pgfplots@zmin\pgfplots@invalidrange@zmin
			\pgfplots@limits@are@computedfalse
		\fi
		\ifx\pgfplots@zmax\pgfplots@invalidrange@zmax
			\pgfplots@limits@are@computedfalse
		\fi
	\fi
	\ifpgfplots@limits@are@computed
		\ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin
			\global\let\pgfplots@data@xmin=\pgfplots@xmin
		\fi
		\ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax
			\global\let\pgfplots@data@xmax=\pgfplots@xmax
		\fi
		\ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin
			\global\let\pgfplots@data@ymin=\pgfplots@ymin
		\fi
		\ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax
			\global\let\pgfplots@data@ymax=\pgfplots@ymax
		\fi
		\ifx\pgfplots@data@zmin\pgfplots@invalidrange@zmin
			\global\let\pgfplots@data@zmin=\pgfplots@zmin
		\fi
		\ifx\pgfplots@data@zmin\pgfplots@invalidrange@zmax
			\global\let\pgfplots@data@zmax=\pgfplots@zmax
		\fi
		\ifpgfplots@clip@limits
		\else
			% there is a rare change that min > max.
			% Handle that ...
			\pgfplotsmathfloatmin{\pgfplots@xmin}{\pgfplots@xmax}%
			\global\let\pgfplots@xmin=\pgfmathresult
			\pgfplotsmathfloatmax{\pgfplots@xmin}{\pgfplots@xmax}%
			\global\let\pgfplots@xmax=\pgfmathresult
			%
			\pgfplotsmathfloatmin{\pgfplots@ymin}{\pgfplots@ymax}%
			\global\let\pgfplots@ymin=\pgfmathresult
			\pgfplotsmathfloatmax{\pgfplots@ymin}{\pgfplots@ymax}%
			\global\let\pgfplots@ymax=\pgfmathresult
			%
			\ifpgfplots@threedim
				\pgfplotsmathfloatmin{\pgfplots@zmin}{\pgfplots@zmax}%
				\global\let\pgfplots@zmin=\pgfmathresult
				\pgfplotsmathfloatmax{\pgfplots@zmin}{\pgfplots@zmax}%
				\global\let\pgfplots@zmax=\pgfmathresult
			\fi
		\fi
	\else
		\pgfplots@handle@invalid@range
	\fi
}%


% This method finishes the accumulated information of axis limits and
% all internal flag fields.
%
% PRECONDITION:  
% 	- all plots are finally finished; axis and data limits are known.
%
% POSTCONDITION:
% 	- the scaling transformation is set-up and applied to all user
% 	inputs and axis limits.
% 	- the \pgfplots@[xy][min,max] variables and associated TeX
% 	registers are set up and final. They should not be changed
% 	afterwards.
% 	- any tick lists etc. are final.
%
\def\pgfplots@determinedefaultvalues{%
	\pgfplots@check@invalid@range
	%
	%--------------------------------------------------
	%FIXME
	% \ifpgfplots@float@numerics@mode@x
	% 	\pgfplotsmathfloatmin{\pgfplots@xmin}{\pgfplots@xmax}%
	% 	\let\pgfplots@xmin=\pgfmathresult
	% 	\pgfplotsmathfloatmax{\pgfplots@xmin}{\pgfplots@xmax}%
	% 	\let\pgfplots@xmax=\pgfmathresult
	% \else
	% 	\pgfplotsmathmin{\pgfplots@xmin}{\pgfplots@xmax}%
	% 	\let\pgfplots@xmin=\pgfmathresult
	% 	\pgfplotsmathmax{\pgfplots@xmin}{\pgfplots@xmax}%
	% 	\let\pgfplots@xmax=\pgfmathresult
	% \fi
	% \ifpgfplots@float@numerics@mode@y
	% 	\pgfplotsmathfloatmin{\pgfplots@ymin}{\pgfplots@ymax}%
	% 	\let\pgfplots@ymin=\pgfmathresult
	% 	\pgfplotsmathfloatmax{\pgfplots@ymin}{\pgfplots@ymax}%
	% 	\let\pgfplots@ymax=\pgfmathresult
	% \else
	% 	\pgfplotsmathmin{\pgfplots@ymin}{\pgfplots@ymax}%
	% 	\let\pgfplots@ymin=\pgfmathresult
	% 	\pgfplotsmathmax{\pgfplots@ymin}{\pgfplots@ymax}%
	% 	\let\pgfplots@ymax=\pgfmathresult
	% \fi
	%-------------------------------------------------- 
%\message{untransformed: x = [\pgfplots@xmin:\pgfplots@xmax]  y = [\pgfplots@ymin:\pgfplots@ymax]. }%
	%
	%
	\pgfplots@set@default@size@options
	%
	\ifpgfplots@threedim
		\pgfplotsthreedimtrue
	\else
		\pgfplotsthreedimfalse
	\fi
	%
	\pgfplots@check@and@apply@datatrafo@for x%
	\pgfplots@check@and@apply@datatrafo@for y%
	\ifpgfplots@threedim
		\pgfplots@check@and@apply@datatrafo@for z%
	\fi
	\pgfplots@datascaletrafo@initialisedtrue
%\message{transformed: x = [\pgfplots@xmin:\pgfplots@xmax]  y = [\pgfplots@ymin:\pgfplots@ymax].}%
	%
	% From now on, we can always work with pgfmath.
	% We simply need to apply the data scaling trafo before doing so.
	\pgfkeysgetvalue{/pgfplots/minor x tick num}\pgfplots@minor@xtick@num
	\ifpgfplots@xislinear
		\ifnum\pgfplots@minor@xtick@num=0\relax
			\pgfplots@xminorticksfalse
			\pgfplots@xminorgridsfalse
		\else
			\pgfplots@xminortickstrue
		\fi
	\fi
	%
	\pgfplots@enlarge@limit@ifconfigured x
	\pgfplots@avoid@empty@axis@range@for x%
	%
	\pgfkeysgetvalue{/pgfplots/minor y tick num}\pgfplots@minor@ytick@num
	\ifpgfplots@yislinear
		\ifnum\pgfplots@minor@ytick@num=0\relax
			\pgfplots@yminorticksfalse
			\pgfplots@yminorgridsfalse
		\else
			\pgfplots@yminortickstrue
		\fi
	\fi
	\pgfplots@enlarge@limit@ifconfigured y
	\pgfplots@avoid@empty@axis@range@for y%

	\ifpgfplots@threedim
		\pgfkeysgetvalue{/pgfplots/minor z tick num}\pgfplots@minor@ztick@num
		\ifpgfplots@zislinear
			\ifnum\pgfplots@minor@ztick@num=0\relax
				\pgfplots@zminorticksfalse
				\pgfplots@zminorgridsfalse
			\else
				\pgfplots@zminortickstrue
			\fi
		\fi
		\pgfplots@enlarge@limit@ifconfigured z
		\pgfplots@avoid@empty@axis@range@for z%
	\fi
	%
	%
	\pgfplots@initsizes
	%
	%
	\pgfplots@BEGIN@prepare@description@styles
	%
	%
	%
	\pgfplots@isuniformticktrue
	\pgfplots@determinedefaultvalues@needs@check@uniformticktrue
	\ifx\pgfplots@xtick\pgfutil@empty
		\pgfplots@assign@default@tick@foraxis{x}%
	\fi
	\ifpgfplots@determinedefaultvalues@needs@check@uniformtick
		\ifpgfplots@xislinear
			\expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@xtick}{\pgfplots@tick@distance@x}%
		\else
			\expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@xtick}%
		\fi
	\fi
	\ifpgfplots@isuniformtick
	\else
		\pgfplots@xminorticksfalse
		\pgfplots@xminorgridsfalse
	\fi
	%
	\if0\pgfplots@xaxislinesnum\else
		% axis x line* != box
		\let\pgfplots@xticklabel@pos=\pgfutil@empty
	\fi
	\if0\pgfplots@yaxislinesnum\else
		% axis y line* != box
		\let\pgfplots@yticklabel@pos=\pgfutil@empty
	\fi
	\if0\pgfplots@zaxislinesnum\else
		% axis y line* != box
		\let\pgfplots@zticklabel@pos=\pgfutil@empty
	\fi
	%
	\ifx\pgfplots@xticklabel@pos\pgfutil@empty
		\def\pgfplots@xticklabel@pos{%
			\if3\pgfplots@xtickposnum% right
				u%
			\else
				l%
			\fi
		}%
	\fi
	\ifx\pgfplots@yticklabel@pos\pgfutil@empty
		\def\pgfplots@yticklabel@pos{%
			\if3\pgfplots@ytickposnum% right
				u%
			\else
				l%
			\fi
		}%
	\fi
	\ifx\pgfplots@zticklabel@pos\pgfutil@empty
		\def\pgfplots@zticklabel@pos{%
			\if3\pgfplots@ztickposnum% right
				u%
			\else
				l%
			\fi
		}%
	\fi
	%
	\ifx\pgfplots@xticklabel\pgfutil@empty
		\ifpgfplots@xislinear
			\def\pgfplots@xticklabel{\axisdefaultticklabel}%
		\else
			\def\pgfplots@xticklabel{\axisdefaultticklabellog}%
		\fi
	\fi
	\ifx\pgfplots@extra@xticklabel\pgfutil@empty
		\let\pgfplots@extra@xticklabel=\pgfplots@xticklabel
	\fi
	%
	%
	%
	\pgfplots@isuniformticktrue
	\pgfplots@determinedefaultvalues@needs@check@uniformticktrue
	\ifx\pgfplots@ytick\pgfutil@empty
		\pgfplots@assign@default@tick@foraxis{y}%
	\fi
	\ifpgfplots@determinedefaultvalues@needs@check@uniformtick
		\ifpgfplots@yislinear
			\expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@ytick}{\pgfplots@tick@distance@y}%
		\else
			\expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@ytick}%
		\fi
	\fi
	\ifpgfplots@isuniformtick
	\else
		\pgfplots@yminorticksfalse
		\pgfplots@yminorgridsfalse
	\fi
	%
	\ifx\pgfplots@yticklabel\pgfutil@empty
		\ifpgfplots@yislinear
			\def\pgfplots@yticklabel{\axisdefaultticklabel}%
		\else
			\def\pgfplots@yticklabel{\axisdefaultticklabellog}%
		\fi
	\fi
	\ifx\pgfplots@extra@yticklabel\pgfutil@empty
		\let\pgfplots@extra@yticklabel=\pgfplots@yticklabel
	\fi
	%
	\ifpgfplots@threedim
		\pgfplots@isuniformticktrue
		\pgfplots@determinedefaultvalues@needs@check@uniformticktrue
		\ifx\pgfplots@ztick\pgfutil@empty
			\pgfplots@assign@default@tick@foraxis{z}%
		\fi
		\ifpgfplots@determinedefaultvalues@needs@check@uniformtick
			\ifpgfplots@zislinear
				\expandafter\pgfplots@checkisuniformLINEARtick\expandafter{\pgfplots@ztick}{\pgfplots@tick@distance@z}%
			\else
				\expandafter\pgfplots@checkisuniformLOGtick\expandafter{\pgfplots@ztick}%
			\fi
		\fi
		\ifpgfplots@isuniformtick
		\else
			\pgfplots@zminorticksfalse
			\pgfplots@zminorgridsfalse
		\fi
		%
		\ifx\pgfplots@zticklabel\pgfutil@empty
			\ifpgfplots@zislinear
				\def\pgfplots@zticklabel{\axisdefaultticklabel}%
			\else
				\def\pgfplots@zticklabel{\axisdefaultticklabellog}%
			\fi
		\fi
		\ifx\pgfplots@extra@zticklabel\pgfutil@empty
			\let\pgfplots@extra@zticklabel=\pgfplots@zticklabel
		\fi
	\fi
	%
	%
	\pgfplots@prepare@ZERO@coordinates
	%
	\pgfplotspoint@initialisation
	%
	\pgfplots@decide@which@figure@surfaces@are@drawn
	%
	\pgfplots@define@threedim@marks
	%
	\pgfplots@clippath@prepare
	%
	\pgfplots@ticklabel@maxtickdimen@reset x%
	\pgfplots@ticklabel@maxtickdimen@reset y%
	\pgfplots@ticklabel@maxtickdimen@reset z%
}

% Defines \pgfmathresult to be the desired width without axis labels.
%
\def\pgfplots@initsizes@get@width@withoutlabels{%
	\pgfplots@initsizes@handle@label@const{\pgfplots@width}{45pt}{width}%
}

% Defines \pgfmathresult to be the desired height without axis labels.
\def\pgfplots@initsizes@get@height@withoutlabels{%
	\pgfplots@initsizes@handle@label@const{\pgfplots@height}{45pt}{height}%
}
\def\pgfplots@initsizes@handle@label@const#1#2#3{%
	\begingroup
	\pgf@xa=#1\relax
	% EXPECTED WIDTH = X = \pgfplots@width
	% ACTUAL WIDTH = c + x * (xmax-xmin)
	% where c is a CONSTANT (for the axis labels/tick labels).
	% -> \pgfplots@tmpXscale = (X - c) / (x *(xmax-xmin))
	%
	% \pgf@xa := X-c:
	\ifpgfplots@scale@only@axis
	\else
		\advance\pgf@xa by-#2 % FIXME determine 'c' correctly!
	\fi
	\ifdim\pgf@xa<0pt
		\pgfplots@error{Error: Plot #3 `#1' is too small. This can't be realised while maintaining constant size for labels. Sorry, label sizes are only approximate. You will need to adjust your #3.}%
		\pgf@xa=0pt
	\fi
	\edef\pgfmathresult{\the\pgf@xa}%
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}%

% Helper method for initsizes.
%
% It computes a scaling such that \pgfplots@width = SCALE * ACTUAL WIDTH.
% 
% The actual width is 
% 	c + x*(xmax-xmin)
% based on
% - c = estimated, a constant for the axis label/tick labels
%
% Arguments: 
% #1: is expected to be x*(xmax-xmin) measured in pt.
% #2: the output argument for the SCALE.
\def\pgfplots@initsizes@getXscale#1\into#2{%
	\begingroup
	\pgfplots@initsizes@get@width@withoutlabels
	% EXPECTED WIDTH = X = \pgfplots@width
	% ACTUAL WIDTH = c + x * (xmax-xmin)
	% where c is a CONSTANT (for the axis labels/tick labels).
	% -> \pgfplots@tmpXscale = (X - c) / (x *(xmax-xmin))
	%
	% \pgf@xa := X-c:
	% \pgf@xb := x*(xmax-xmin):
	\pgf@xa=\pgfmathresult\relax
	\pgf@xb=#1\relax
	\pgfmathlog@invoke@expanded\pgfmathdivide@{%
		{\pgf@sys@tonumber\pgf@xa}%
		{\pgf@sys@tonumber\pgf@xb}%
	}%
%\pgfplots@message{pgfplots.sty: Computing 'x' such that 'width = c + x*(xmax-xmin)';
%	c=estimated, 
%	width-c =\the\pgf@xa,  
%	x*(xmax[=\the\pgfplots@xcoordmaxTEX] - xmin[=\the\pgfplots@xcoordminTEX)]) = \the\pgf@xb  
%	-> x-scale =#2 }%
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
	\let#2=\pgfmathresult
}

% The same as \pgfplots@initsizes@getXscale, just for the height.
\def\pgfplots@initsizes@getYscale#1\into#2{%
	\begingroup
	\pgfplots@initsizes@get@height@withoutlabels
	% \pgf@xb := y*(ymax-ymin):
	\pgf@xa=\pgfmathresult\relax
	\pgf@xb=#1%
	\pgfmathlog@invoke@expanded\pgfmathdivide@{%
		{\pgf@sys@tonumber\pgf@xa}%
		{\pgf@sys@tonumber\pgf@xb}%
	}%
%\pgfplots@message{pgfplots.sty: Computing 'y' such that 'height = c + y*(ymax-ymin)';
%	height=\pgfplots@height,
%	c=estimated,
%	height-c =\the\pgf@xa,  
%	y*(ymax[=\the\pgfplots@ycoordmaxTEX] - ymin[=\the\pgfplots@ycoordminTEX)]) = \the\pgf@xb  
%	-> y-scale =#2 }%
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
	\let#2=\pgfmathresult
}


\newif\ifpgfplots@avoid@emptyrange@@range@is@approx@equal
% Checks whether axis limits in coordinate #1 are approximately equal.
%
% If that is the case, force a non-zero width of the range.
%
\def\pgfplots@avoid@empty@axis@range@for#1{%
	% Check if axis limits are empty:
	\begingroup
	\expandafter\let\expandafter\if@cur@is@scaled\csname ifpgfplots@apply@datatrafo@#1\endcsname
	\expandafter\let\expandafter\pgfplots@@min\csname pgfplots@#1min\endcsname
	\expandafter\let\expandafter\pgfplots@@max\csname pgfplots@#1max\endcsname
	\let\min@d=\pgf@xa
	\let\max@d=\pgf@xb
	\let\diff=\pgf@xc
	\expandafter\min@d\pgfplots@@min pt %
	\expandafter\max@d\pgfplots@@max pt %
	\diff=\max@d
	\advance\diff by-\min@d
	% FIXME : I need a RELATIVE check here!
	% but: real number point division is expensive
	\if@cur@is@scaled
		% this here should be sufficient because the axis
		% has absolute values of order O( 10^3 ) or so.
		\ifdim\diff<0.0001pt
			\pgfplots@avoid@emptyrange@@range@is@approx@equaltrue
		\fi
	\else
		% there is no data scaling, so I should be much more defensive
		% with absolute thresholds...
		\ifdim\diff<0.0001pt
			\pgfplots@avoid@emptyrange@@range@is@approx@equaltrue
		\fi
	\fi
	\ifpgfplots@avoid@emptyrange@@range@is@approx@equal
		\pgfplots@warning{Axis range for axis #1 is approximately empty; enlargeing it.}%
		% the case \pgfplots@@min ~= \pgfplots@@max
		%
		% enlarge \pgfplots@@max and shrink \min:
		\ifdim\max@d<0pt%
			\ifdim\max@d<-1pt%
				\max@d=0.8\max@d
				\min@d=1.2\min@d
			\else
				\advance\max@d by-1pt%
				\advance\min@d by1pt%
			\fi
		\else
			\ifdim\max@d>1pt%
				\max@d=1.2\max@d
				\min@d=0.8\min@d
			\else
				\ifdim\max@d=0pt%
					\if@cur@is@scaled
						\expandafter\let\expandafter\min@unscaled\csname pgfplots@#1min@unscaled@as@float\endcsname
						\expandafter\let\expandafter\max@unscaled\csname pgfplots@#1max@unscaled@as@float\endcsname
						% **sigh**. That's really work.
						%
						% This here happens ALWAYS if min == max for
						% linear axis because the scaling
						% transformation will result in T(min) = T(max) = 0
						%
						% -> we need to enlarge limits in floating
						%  point arithmetics.
						%
						\pgfmathfloatcreate{0}{0.0}{0}%
						\let\pgfplotsmath@zero=\pgfmathresult
						%
						\ifx\max@unscaled\pgfplotsmath@zero
							% max == 0
							\pgfmathfloatcreate{1}{1.0}{0}%
							\let\max@unscaled=\pgfmathresult
							\pgfmathfloatcreate{2}{1.0}{0}%
							\let\min@unscaled=\pgfmathresult
						\else
							%
							\pgfmathfloatcreate{1}{1.2}{0}%
							\let\pgfplotsmath@scalea=\pgfmathresult
							\pgfmathfloatcreate{1}{8.0}{-1}%
							\let\pgfplotsmath@scaleb=\pgfmathresult
							%
							\pgfmathfloatlessthan@{\pgfplotsmath@zero}{\max@unscaled}%
							\ifpgfmathfloatcomparison
								% 0 < max
								\pgfmathfloatmultiply@{\max@unscaled}{\pgfplotsmath@scalea}%
								\let\max@unscaled=\pgfmathresult
								\pgfmathfloatmultiply@{\min@unscaled}{\pgfplotsmath@scaleb}%
								\let\min@unscaled=\pgfmathresult
							\else
								\pgfmathfloatmultiply@{\max@unscaled}{\pgfplotsmath@scaleb}%
								\let\max@unscaled=\pgfmathresult
								\pgfmathfloatmultiply@{\min@unscaled}{\pgfplotsmath@scalea}%
								\let\min@unscaled=\pgfmathresult
							\fi
						\fi
						\csname pgfplots@datascaletrafo@#1\endcsname{\min@unscaled}%
						\let\pgfplots@@min=\pgfmathresult
						\csname pgfplots@datascaletrafo@#1\endcsname{\max@unscaled}%
						\let\pgfplots@@max=\pgfmathresult
						\min@d=\pgfplots@@min pt
						\max@d=\pgfplots@@max pt
					\else
						\advance\max@d by1pt
						\advance\min@d by-1pt
					\fi
				\else
					\advance\max@d by1pt
					\advance\min@d by-1pt
				\fi
			\fi
		\fi
		\xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber{\min@d}}%
		\xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\max@d}}%
%\pgfplots@message{ -> #1 = \pgfplots@glob@TMPa : \pgfplots@glob@TMPb;}%
	\else
		\global\let\pgfplots@glob@TMPa=\pgfplots@@min%
		\global\let\pgfplots@glob@TMPb=\pgfplots@@max%
	\fi
	\endgroup
	\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfplots@glob@TMPa
	\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfplots@glob@TMPb
}

% PRECONDITION:
% 	none
% POSTCONDITION:
% 	\pgfplots@default@aspect@ratio is set.
\def\pgfplots@compute@default@aspect@ratio{%
	\expandafter\pgfmath@x\axisdefaultwidth
	\expandafter\pgfmath@y\axisdefaultheight
	\pgfmathlog@invoke@expanded\pgfmathdivide@{%
		{\pgf@sys@tonumber{\pgfmath@x}}%
		{\pgf@sys@tonumber{\pgfmath@y}}%
	}%
	\let\pgfplots@default@aspect@ratio=\pgfmathresult
}

\def\pgfplots@set@default@size@options{%
	% The axes 'x' and 'y' vectors will be scaled such that the total
	% size is (\axisdefaultwidth, \axisdefaultheight).
	%
	% If the user specifies ONE of width OR height, 
	% the plot will be resized; keeping the aspect ratio.
	%
	\let\pgfplots@default@aspect@ratio=\pgfutil@empty
	\pgfkeysgetvalue{/pgfplots/x}{\pgfplots@x}%
	\pgfkeysgetvalue{/pgfplots/y}{\pgfplots@y}%
	\pgfkeysgetvalue{/pgfplots/z}{\pgfplots@z}%
	\pgfkeysgetvalue{/pgfplots/width}{\pgfplots@width}%
	\pgfkeysgetvalue{/pgfplots/height}{\pgfplots@height}%
	\ifx\pgfplots@width\pgfutil@empty
	\else
		\pgfmathparse{\pgfplots@width}%
		\edef\pgfplots@width{\pgfmathresult pt}%
	\fi
	\ifx\pgfplots@height\pgfutil@empty
	\else
		\pgfmathparse{\pgfplots@height}%
		\edef\pgfplots@height{\pgfmathresult pt}%
	\fi
	%
	% CASES:
	% hasx := 'x' option non-empty
	% hasy := 'y' option non-empty
	% W := 'width' option non-empty
	% H := 'height' option non-empty
	%
	% hasx = 1 -> width is not interesting; we use 'x' option.
	% hasx = 0 -> determine final width:
	% 		W H
	% 		0 0 -> \axisdefaultwidth 
	% 		0 1 -> determine width out of H and the default aspect ratio
	% 		1 X -> ok, use the user parameter.
	%
	% hasy = 1 -> height is not interesting, we use 'y' option.
	% hasy = 0 -> determine final height:
	% 		W H
	% 		0 0 -> \axisdefaultheight
	% 		X 1 -> ok, use the user parameter
	% 		1 0 -> determine height out of W and the default aspect ratio
	%
	\ifx\pgfplots@x\pgfutil@empty
		\ifx\pgfplots@y\pgfutil@empty
			% hasx=0, hasy=0 
			%
			% -> KEEP ASPECT RATIO if just one W, or H is given!
			\ifx\pgfplots@width\pgfutil@empty
				\ifx\pgfplots@height\pgfutil@empty
					% The case hasx=0, hasy=0,  W=0 H=0:
					\let\pgfplots@width=\axisdefaultwidth
					\let\pgfplots@height=\axisdefaultheight
				\else
					% The case hasx=0, hasy=0,  W=0 H=1:
					\pgfplots@compute@default@aspect@ratio
					\expandafter\pgfmath@y\pgfplots@height
					\pgfmathlog@invoke@expanded\pgfmathmultiply@{%
						{\pgf@sys@tonumber{\pgfmath@y}}%
						{\pgfplots@default@aspect@ratio}%
					}%
					\edef\pgfplots@width{\pgfmathresult pt}%
				\fi
			\else
				\ifx\pgfplots@height\pgfutil@empty
					% The case hasx=0, hasy=0,  W=1 H=0:
					\pgfplots@compute@default@aspect@ratio
					\expandafter\pgfmath@x\pgfplots@width
					\pgfmathlog@invoke@expanded\pgfmathdivide@{%
						{\pgf@sys@tonumber{\pgfmath@x}}%
						{\pgfplots@default@aspect@ratio}%
					}%
					\edef\pgfplots@height{\pgfmathresult pt}%
				\else
					% The case hasx=0, hasy=0,  W=1 H=1:
				\fi
			\fi
		\else
			% hasx=0, hasy=1, W=0:
			\ifx\pgfplots@width\pgfutil@empty
				\let\pgfplots@width=\axisdefaultwidth
			\fi
		\fi
	\else
		\ifx\pgfplots@y\pgfutil@empty
			% hasx=1, hasy=0, H=0
			\ifx\pgfplots@height\pgfutil@empty
				\let\pgfplots@height=\axisdefaultheight
			\fi
		\fi
	\fi
	\pgfkeyslet{/pgfplots/width}{\pgfplots@width}%
	\pgfkeyslet{/pgfplots/height}{\pgfplots@height}%
}

% A helper method for \pgfplots@initsizes which
% - applies the data scaling trafo to user arguments
% - sets calls pgfset#1vec
% - computes \pgfplots@#1@veclength
% - computes \pgfplots@#1@inverseveclength
%
% #1: the vector to set (either 'x' or 'y')
% #2: the index of the vector to set (either 0 or 1)
% #3: the already precomputed temporary scale (see pgfplots@initsizes)
% #4: an output argument. It is a macro name which will be defined to
% '1' if and only if the finally set vector is parallel to the #1 axis
% of PGF, that means (x,0) for #1=x and (0,y) for #2=y.
\def\pgfplots@initsizes@setunitvector#1#2#3#4{%
	\pgfkeysgetvalue{/pgfplots/#1 dir/value}\pgfplots@loc@dirvalue
	\expandafter\let\expandafter\pgfplots@loc@TMPb\csname pgfplots@#1\endcsname
	\ifx\pgfplots@loc@TMPb\pgfutil@empty
		\def#4{1}% we have (#1,0) or (0,#1)
		%
%\message{Setting unitvector(#1) to auto-computed multiple of e_#2 ...}%
		\edef\pgfplots@loc@TMPa{#3}%
		\if r\pgfplots@loc@dirvalue
			\edef\pgfplots@loc@TMPa{-#3}%
		\fi
		\begingroup
			\pgf@xa=#3\relax
			\xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
		\endgroup
% FIXME : '\pgfplots@loc@TMPa' contains 'pt' leading to missing
% character warning!
		\ifcase#2\relax
			\pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPa}{0pt}}%
			\pgfmathabs@{\pgfplots@glob@TMPb}%
		\or
			\pgfsetyvec{\pgfqpoint{0pt}{\pgfplots@loc@TMPa}}%
			\pgfmathabs@{\pgfplots@glob@TMPb}%
		\or
			\pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPa}}%
			\ifdim\pgfplots@loc@TMPa=0pt
				\def\pgfmathresult{0}%
			\else
				\pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}%
			\fi
		\fi
		% The numbers 1/||e_x|| and 1/||e_y|| are used by the tick
		% placement code to convert between logical and physical
		% coordinates.
		\expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult
		\pgfplotsmath@ifzero{\pgfmathresult}{%
			\expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}%
		}{%
			\expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
			\expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult
		}%
	\else
		% Ok, we have a user-defined unit vector.
		%
		% That means we also need to apply the scaling trafo!
		%
		\if r\pgfplots@loc@dirvalue
			\def\pgfplots@loc@dirvalue{-}%
		\else
			\def\pgfplots@loc@dirvalue{}%
		\fi
		%
		% 1. Check whether we have a complete vector of type (x,y):
		\expandafter\pgfutil@in@\expandafter(\expandafter{\pgfplots@loc@TMPb}%
		\ifpgfutil@in@
			% YES: we have (x,y):
			%
			\def#4{0}% we DON'T have (#1,0) or (0,#1). At least I think so.
			%
%\message{Setting unitvector(#1) to non-standard \csname pgfplots@#1\endcsname ...}%
			% FIXME : that's wrong for 3D axes!
			\def\pgfplots@loc@TMPa(##1,##2){%
				\pgfmathparse{##1}%
				\let\pgfplots@loc@TMPb=\pgfmathresult
				\pgfmathparse{##2}%
				\let\pgfplots@loc@TMPc=\pgfmathresult
				%
				\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
					\csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPb}%
					\let\pgfplots@loc@TMPb=\pgfmathresult
					\csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname{\pgfplots@loc@TMPc}%
					\let\pgfplots@loc@TMPc=\pgfmathresult
				}{}%
				\csname pgfset#1vec\endcsname{%
					\pgfqpoint
						{\pgfplots@loc@dirvalue\pgfplots@loc@TMPb pt}
						{\pgfplots@loc@dirvalue\pgfplots@loc@TMPc pt}}%
			}%
			\expandafter\pgfplots@loc@TMPa\pgfplots@loc@TMPb%
			%
			\pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}%
			\expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult
			\pgfplotsmath@ifzero{\pgfmathresult}{%
				\expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}%
			}{%
				\expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
				\expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult
			}%
		\else
			% NO we simply have a scalar value.
			\def#4{1}% we have (#1,0) or (0,#1)
%\message{Setting unitvector(#1) to \csname pgfplots@#1\endcsname * e_{#2}...}%
			\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
				\pgfmathparse{\csname pgfplots@#1\endcsname}%
				\expandafter\expandafter\csname pgfplots@inverse@datascaletrafo@tofixed@#1@noshift\endcsname\expandafter{\pgfmathresult}%
				\edef\pgfplots@loc@TMPb{\pgfmathresult pt}%
			}{\relax}%
			\begingroup
				\pgf@xa=\pgfplots@loc@TMPb\relax
				\if r\pgfplots@loc@dirvalue
					\multiply\pgf@xa by-1
				\fi
				\xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
			\endgroup
			\ifcase#2\relax
				\pgfsetxvec{\pgfqpoint{\pgfplots@loc@TMPb}{0pt}}%
				\pgfmathabs@{\pgfplots@glob@TMPb}%
			\or
				\pgfsetyvec{\pgfqpoint{0pt}{\pgfplots@loc@TMPb}}%
				\pgfmathabs@{\pgfplots@glob@TMPb}%
			\or
				\pgfsetzvec{\pgfqpoint{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPb}}%
				\ifdim\pgfplots@loc@TMPb=0pt
					\def\pgfmathresult{0}%
				\else
					\pgfmathveclen{\csname pgf@#1x\endcsname}{\csname pgf@#1y\endcsname}%
				\fi
			\fi
			\expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult
			\pgfplotsmath@ifzero{\pgfmathresult}{%
				\expandafter\def\csname pgfplots@#1@inverseveclength\endcsname{infty}%
			}{%
				\expandafter\pgfmathreciprocal@\expandafter{\pgfmathresult}%
				\expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult
			}%
		\fi
	\fi
%\message{-> got unitvector(#1) = (\the\csname pgf@#1x\endcsname, \the\csname pgf@#1y\endcsname).}%
}%

% Applies the 'axis equal' feature.
%
% PRECONDITION:
% 	- final unit vectors have been set
% 	- final axis limits are given in transformed range
% 	-  \pgfplots@set@default@size@options has been invoked before
%
% POSTCONDITION:
% 	- unit vectors have been set to equal length,
% 	- axis limits have been rescaled such that the axis dimensions
% 	remain fixed
%
% There is just one algorithmic difficulty: the data scaling
% transformation. All unit vector length above are only meaningful in
% the UNTRANSFORMED range, so we have to mingle with the scaling
% transformation.
\def\pgfplots@axis@equal@apply{%
	% Step 1: compute the unit vector which STAYS CONSTANT.
	%
	% All other ones will be scaled to fit its length.
	\ifpgfplots@threedim
		\def\pgfplots@axis@equal@apply@reference{x}%
		\pgfplots@if@unitveclenlessthan@untransformed xy{%
			\pgfplots@if@unitveclenlessthan@untransformed xz{%
				\def\pgfplots@axis@equal@apply@reference{x}%
			}{}%
		}{}%
		\pgfplots@if@unitveclenlessthan@untransformed yx{%
			\pgfplots@if@unitveclenlessthan@untransformed yz{%
				\def\pgfplots@axis@equal@apply@reference{y}%
			}{}%
		}{}%
		\pgfplots@if@unitveclenlessthan@untransformed zx{%
			\pgfplots@if@unitveclenlessthan@untransformed zy{%
				\def\pgfplots@axis@equal@apply@reference{z}%
			}{}%
		}{}%
	\else
		\pgfplots@if@unitveclenlessthan@untransformed xy{%
			\def\pgfplots@axis@equal@apply@reference{x}%
		}{%
			\def\pgfplots@axis@equal@apply@reference{y}%
		}%
	\fi
%\message{USING REFERENCE UNIT VECTOR FROM \pgfplots@axis@equal@apply@reference.}%
	\if x\pgfplots@axis@equal@apply@reference
	\else
		\pgfplots@axis@equal@apply@for x
	\fi
	\if y\pgfplots@axis@equal@apply@reference
	\else
		\pgfplots@axis@equal@apply@for y
	\fi
	\ifpgfplots@threedim
		\if z\pgfplots@axis@equal@apply@reference
		\else
			\pgfplots@axis@equal@apply@for z
		\fi
	\fi
}%

% Scales unit vector '#1' such that it has the same length as the unit
% vector in direction \pgfplots@axis@equal@apply@reference.
%
% The data limits for '#1' will be enlarged as well (for 'axis
% equal').
\def\pgfplots@axis@equal@apply@for#1{%
	\pgfmathmultiply@
		{\csname pgfplots@\pgfplots@axis@equal@apply@reference @veclength\endcsname}
		{\csname pgfplots@#1@inverseveclength\endcsname}%
	\global\let\pgfplots@glob@TMPa=\pgfmathresult
	\pgfmathmultiply@
		{\csname pgfplots@\pgfplots@axis@equal@apply@reference @inverseveclength\endcsname}
		{\csname pgfplots@#1@veclength\endcsname}%
	\global\let\pgfplots@glob@TMPb=\pgfmathresult
	% 
	% If the datascaling transformation is active (which is almost
	% everytime the case here), we need to respect it here.
	%
	% We only need to respect the SCALING, translations (shifts) are
	% not interesting.
	%
	% We want that || T^{-1} e_ref || = || T^{-1} E_#1 ||.
	%
	% So: T^{-1} E_#1 :=  s* T^{-1} e_#1 where 
	%  s = ||T^{-1} e_ref|| / || T^{-1} e_#1 || 
	%    = |10^{scale_ref}| / |10^{scale_#1}| * || e_ref|| / ||e_#1||.
	% 
	% Then, E_#1 = T ( T^{-1} E_#1 ) = s * e_#1.
	%
	% -> compute 's'! We already have the quotient of unit vectors.
	%  Now, acquire the scale quotients.
	%
	\begingroup
		\def\pgfplots@tmp@exponentref{0}%
		\def\pgfplots@tmp@exponentK{0}%
		\pgfplots@if{pgfplots@apply@datatrafo@\pgfplots@axis@equal@apply@reference}{%
			\pgfplots@letcsname{pgfplots@tmp@exponentref}={pgfplots@data@scale@trafo@EXPONENT@\pgfplots@axis@equal@apply@reference}%
		}{}%
		\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
			\pgfplots@letcsname{pgfplots@tmp@exponentK}={pgfplots@data@scale@trafo@EXPONENT@#1}%
		}{}%
		\c@pgf@counta=\pgfplots@tmp@exponentref
		\advance\c@pgf@counta by-\pgfplots@tmp@exponentK
		\ifnum\c@pgf@counta=0
		\else
			\pgfplotsmathmultiplypowten@{\pgfplots@glob@TMPa}{\c@pgf@counta}%
			\global\let\pgfplots@glob@TMPa=\pgfmathresult
			\pgfplotsmathmultiplypowten@{\pgfplots@glob@TMPb}{-\c@pgf@counta}%
			\global\let\pgfplots@glob@TMPb=\pgfmathresult
		\fi
		\xdef\pgfplots@glob@TMPc{\the\c@pgf@counta}%
	\endgroup
	%
	\if x#1
		\pgfsetxvec{\pgfplotsqpointxy{\pgfplots@glob@TMPa}{0}}%
	\else
		\if y#1
			\pgfsetyvec{\pgfplotsqpointxy{0}{\pgfplots@glob@TMPa}}%
		\else
			\if z#1
				\pgfsetzvec{\pgfplotsqpointxyz{0}{0}{\pgfplots@glob@TMPa}}%
			\fi
		\fi
	\fi
	%
 	% 
	% Update auxiliary data members:
	% This is only complicated due to the scaling transformation. If we would not have the scaling trafo, the following
	% code would simply copy the vector length and inverse vectors length from the reference axis.
	\pgfplotsmathmultiplypowten@{\csname pgfplots@\pgfplots@axis@equal@apply@reference @veclength\endcsname}{\pgfplots@glob@TMPc}%
	\expandafter\let\csname pgfplots@#1@veclength\endcsname=\pgfmathresult
	\pgfplotsmathmultiplypowten@{\csname pgfplots@\pgfplots@axis@equal@apply@reference @inverseveclength\endcsname}{-\pgfplots@glob@TMPc}%
	\expandafter\let\csname pgfplots@#1@inverseveclength\endcsname=\pgfmathresult
	%
	%
	\ifpgfplots@axis@equal@image
	\else
		%
		% Ok, now update the axis limits such that the axis' dimensions
		% stay the same.
		%
		% My idea is to add half of the new range to 'max' and
		% subtract the other half from 'min':
		% 1/s( xmax - xmin) = (xmax+0.5d) - (xmin-0.5d) = xmax - xmin +d
		% with d = 1/s (xmax-xmin) - (xmax-xmin) = (1/s - 1) (xmax-xmin)
		% 
%\message{'axis equal': Resizing data range for #1: from \csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname\ to}%
		\pgfmathsubtract@{\csname pgfplots@#1max\endcsname}{\csname pgfplots@#1min\endcsname}%
		\begingroup
			\pgf@xa=\pgfmathresult pt
			\pgfmathsubtract@{\pgfplots@glob@TMPb}{1.0}%
			\pgf@xa=\pgfmathresult \pgf@xa
			\divide\pgf@xa by2
			\xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\pgf@xa}}%
		\endgroup
		\pgfmathsubtract@{\csname pgfplots@#1min\endcsname}{\pgfplots@glob@TMPb}%
		\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
		\pgfmathadd@{\csname pgfplots@#1max\endcsname}{\pgfplots@glob@TMPb}%
		\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
%\message{\csname pgfplots@#1min\endcsname:\csname pgfplots@#1max\endcsname. [+- \pgfplots@glob@TMPb]}%
		%
		% Update auxiliary data members:
		\pgfplots@visphase@notify@changeofcanvaslimits{#1}%
	\fi
}

% should be invoked whenever \pgfplots@#1min or \pgfplots@#1max have
% been changed during the visualization phase (for example, axis equal
% or enlargelimits)
\def\pgfplots@visphase@notify@changeofcanvaslimits#1{%
	\csname pgfplots@#1min@reg\endcsname=\csname pgfplots@#1min\endcsname pt %
	\csname pgfplots@#1max@reg\endcsname=\csname pgfplots@#1max\endcsname pt %
	\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
		\csname pgfplots@inverse@datascaletrafo@#1\endcsname{\csname pgfplots@#1min\endcsname}%
		\expandafter\let\csname pgfplots@#1min@unscaled@as@float\endcsname=\pgfmathresult
		\csname pgfplots@inverse@datascaletrafo@#1\endcsname{\csname pgfplots@#1max\endcsname}%
		\expandafter\let\csname pgfplots@#1max@unscaled@as@float\endcsname=\pgfmathresult
	}{}%
}%

% Invokes #3 if 
% ( 10^{s1} * veclen1 < 10^{s2} * veclen2 )
%   <=>
% ( 10^{s1-s2} * veclen1 < veclen2 ).
%
% If the condition is false, '#4' is invoked.
\def\pgfplots@if@unitveclenlessthan@untransformed#1#2#3#4{%
	\def\pgfplots@loc@TMPa{0}%
	\def\pgfplots@loc@TMPb{0}%
	\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
		\pgfplots@letcsname{pgfplots@loc@TMPa}={pgfplots@data@scale@trafo@EXPONENT@#1}%
	}{}%
	\pgfplots@if{pgfplots@apply@datatrafo@#2}{%
		\pgfplots@letcsname{pgfplots@loc@TMPb}={pgfplots@data@scale@trafo@EXPONENT@#2}%
	}{}%
	\begingroup
	\pgf@xb=\csname pgfplots@#2@veclength\endcsname pt
	\c@pgf@counta=\pgfplots@loc@TMPa
	\advance\c@pgf@counta by-\pgfplots@loc@TMPb
	\ifnum\c@pgf@counta=0
		\pgf@xa=\csname pgfplots@#1@veclength\endcsname pt
	\else
		\pgfplotsmathmultiplypowten@{\csname pgfplots@#1@veclength\endcsname}{\c@pgf@counta}%
		\pgf@xa=\pgfmathresult pt
	\fi
	\ifdim\pgf@xa<\pgf@xb
		\gdef\pgfplots@glob@TMPc{1}%
	\else
		\gdef\pgfplots@glob@TMPc{0}%
	\fi
	\endgroup
	\if1\pgfplots@glob@TMPc #3\else #4\fi
}%

% PRECONDITION: 
% 	- final axis limits are given in transformed range
% 	-  \pgfplots@set@default@size@options has been invoked before
% POSTCONDITION: 
% 	- the current x,y and z unit vectors are defined properly;
% 	- the fast-access registers are initialised for the axis limits,
%	- the following macros are assigned:
%		\pgfplots@[xyz]@veclength
%		\pgfplots@[xyz]@inverseveclength
%		\pgfplotspointxaxis
%		\pgfplotspointyaxis
%		\pgfplotspointzaxis
%		\pgfplotspointcenter
%		\pgfplotspointminminmin
%
\def\pgfplots@initsizes{%
	% INIT.
	%
	%
	\pgfplots@xmin@reg=\pgfplots@xmin pt %
	\pgfplots@xmax@reg=\pgfplots@xmax pt %
	\pgfplots@ymin@reg=\pgfplots@ymin pt %
	\pgfplots@ymax@reg=\pgfplots@ymax pt %
	\ifpgfplots@threedim
		\pgfplots@zmin@reg=\pgfplots@zmin pt %
		\pgfplots@zmax@reg=\pgfplots@zmax pt %
	\fi
	%
	\pgfpointdiff
		{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}}
		{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}%
	% only used temporarily in this macro to compute the correct
	% length for unit vectors:
	\edef\pgfplots@initsizes@axisdiag@x{\the\pgf@x}%
	\edef\pgfplots@initsizes@axisdiag@y{\the\pgf@y}%
	%
	%
	%-----------------------------------------
	% PROCESS THE 'width' and 'height' options
	%-----------------------------------------
	%
	%
	\pgfkeysgetvalue{/pgfplots/view/az}{\pgfplots@view@az}%
	\pgfkeysgetvalue{/pgfplots/view/el}{\pgfplots@view@el}%
	\ifpgfplots@threedim
		\def\pgfplots@tmpZscale{1pt}%
	\else
		\def\pgfplots@tmpZscale{0pt}%
		% FIXME
		\let\pgfplots@view@el=\pgfutil@empty
		\let\pgfplots@view@az=\pgfutil@empty
		\def\pgfplots@view@dir@threedim@x{0}%
		\def\pgfplots@view@dir@threedim@y{0}%
		\def\pgfplots@view@dir@threedim@z{1}%
	\fi
	\ifx\pgfplots@view@az\pgfutil@empty
		%\let\pgfplots@rectangle@width=\pgfutil@empty
		%\let\pgfplots@rectangle@height=\pgfutil@empty
		%
		\ifx\pgfplots@x\pgfutil@empty
			\ifx\pgfplots@width\pgfutil@empty
				\pgfplots@error{INTERNAL LOGIC ERROR! WIDTH NOT SET}%
			\fi
			\pgfplots@initsizes@getXscale\pgfplots@initsizes@axisdiag@x\into\pgfplots@tmpXscale
			%\ifpgfplots@scale@only@axis
			%	\let\pgfplots@rectangle@width=\pgfplots@width
			%\fi
		\else
			\def\pgfplots@tmpXscale{1}%
		\fi
		%
		\ifx\pgfplots@y\pgfutil@empty
			\ifx\pgfplots@height\pgfutil@empty
				\pgfplots@error{INTERNAL LOGIC ERROR! HEIGHT NOT SET}%
			\fi
			\pgfplots@initsizes@getYscale\pgfplots@initsizes@axisdiag@y\into\pgfplots@tmpYscale
			%\ifpgfplots@scale@only@axis
			%	\let\pgfplots@rectangle@height=\pgfplots@height
			%\fi
		\else
			\def\pgfplots@tmpYscale{1}%
		\fi
		%
		\pgfplotsqpointxy{\pgfplots@tmpXscale}{\pgfplots@tmpYscale}%
		\edef\pgfplots@tmpXscale{\the\pgf@x}%
		\edef\pgfplots@tmpYscale{\the\pgf@y}%
		%
		\pgfplots@initsizes@setunitvector{x}{0}{\pgfplots@tmpXscale}{\pgfplots@tmp@xisaxisparallel}%
		\pgfplots@initsizes@setunitvector{y}{1}{\pgfplots@tmpYscale}{\pgfplots@tmp@yisaxisparallel}%
		\pgfplots@initsizes@setunitvector{z}{2}{\pgfplots@tmpZscale}{\pgfplots@loc@TMPc}%
	\else
		% 3D case is currently always initialised by `view':
		\let\pgfplots@x=\pgfutil@empty
		\let\pgfplots@y=\pgfutil@empty
		\let\pgfplots@z=\pgfutil@empty
		\pgfplotssetaxesfromazel{\pgfplots@view@az}{\pgfplots@view@el}{\pgfplots@tmp@xisaxisparallel}%
		\if1\pgfplots@tmp@xisaxisparallel%
			\def\pgfplots@tmp@yisaxisparallel{1}%
		\fi
	\fi
%\message{Pgfplots debug: initialised unit vectors to x=(\the\pgf@xx,\the\pgf@xy), y=(\the\pgf@yx,\the\pgf@yy), z=(\the\pgf@zx,\the\pgf@zy). }%
	%
	\let\pgfplotsmathfloatviewdepthxyz@=\pgfplotsmathfloatviewdepthxyz@infigure
	\let\pgfplotsmathviewdepthxyz@=\pgfplotsmathviewdepthxyz@infigure
	%
	\pgfplotsmath@ifzero{\pgfplots@x@veclength}{\pgfplots@hide@xtrue\pgfplots@shownothingof@xtrue}{}%
	\pgfplotsmath@ifzero{\pgfplots@y@veclength}{\pgfplots@hide@ytrue\pgfplots@shownothingof@ytrue}{}%
	\ifpgfplots@threedim
		\pgfplotsmath@ifzero{\pgfplots@z@veclength}{\pgfplots@hide@ztrue\pgfplots@shownothingof@ztrue}{}%
	\else
		\if1\pgfplots@tmp@xisaxisparallel%
			\if1\pgfplots@tmp@yisaxisparallel%
				% Optimize for axis-parallel case!
				% puh. Did not make any measureable difference!? Ok...
				\let\pgfplotsqpointxy=\pgfplotsqpointxy@orthogonal
			\fi
		\fi
	\fi
	\ifpgfplots@axis@equal@image
		\pgfplots@axis@equaltrue
	\fi
	\ifpgfplots@axis@equal
		\pgfplots@axis@equal@apply
	\fi
	%
	% Determine final rectangle dimensions.
	% There are the following cases: 
	% 1. the user really wants a fixed dimension,
	%    i.e. he used 'scale only axis'.
	%    Then, we have to work to get the correct dimension!
	%
	%    Up to now, the scaling mechanism looses to many significant
	%    digits such that the final width/height differs by 1-2 pt.
	%
	%    If I am not mistaken, this does ONLY affect the final size,
	%    not the relative plot precision.
	%    
	%    FIXME : really compute the plot precision!
	% 
	% 2. The use specified width and/or height, but not 'scale only
	%    axis'. Accept inaccurate final widths/heights (see above).
	%
	% 3. The user supplied 'x' and or 'y'. Simply use them, its
	% accurate.
	%
	\begingroup
	\ifpgfplots@threedim
		\def\pgfplotspointmaxminmin{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
		\def\pgfplotspointminmaxmin{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
		\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}%
	\else
		\def\pgfplotspointmaxminmin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}%
		\def\pgfplotspointminmaxmin{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}%
		\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}%
	\fi
	\xdef\pgfplotspointminminmin{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	% ATTENTION: I re-use registers here! Make sure they won't be
	% overwritten! \pgfpointdiff and \pgfplotsqpointxy are ok in this respect.
	\let\pgfplots@xcoordminTEX=\pgf@xb
	\let\pgfplots@ycoordminTEX=\pgf@yb
	\pgfplots@xcoordminTEX=\pgf@x
	\pgfplots@ycoordminTEX=\pgf@y
	%
	%--------------------------------------------------
	% FIXME : WHAT IS THIS HERE FOR? 
	% \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
	% \ifx\pgfplots@rectangle@width\pgfutil@empty
	% 	\def\pgfplots@tmp@xmax@ymin{\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}%
	% \else
	% 	% this 'if' here should only make a difference of about
	% 	% 1-2pt, not more.
	% 	%
	% 	% and I am quite sure that this inaccuracy (and this
	% 	% work-around) only affects the
	% 	% final size, not the relative plot accuracy.
	% 	\pgf@x=\pgfplots@xcoordminTEX
	% 	\advance\pgf@x by\pgfplots@width
	% 	\edef\pgfplots@tmp@xmax@ymin{\noexpand\pgfqpoint{\the\pgf@x}{\noexpand\pgfplots@ycoordminTEX}}%
	% \fi
	% \ifx\pgfplots@rectangle@height\pgfutil@empty
	% 	\def\pgfplots@tmp@xmin@ymax{\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}}%
	% \else
	% 	\pgf@x=\pgfplots@ycoordminTEX
	% 	\advance\pgf@x\pgfplots@height
	% 	\edef\pgfplots@tmp@xmin@ymax{\noexpand\pgfqpoint{\noexpand\pgfplots@xcoordminTEX}{\the\pgf@x}}%
	% \fi
	%-------------------------------------------------- 
	\pgfpointdiff
		{\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}}
		{\pgfplotspointmaxminmin}%
	\xdef\pgfplotspointxaxis{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	\pgfmathveclen{\pgf@x}{\pgf@y}%
	\xdef\pgfplotspointxaxislength{\pgfmathresult pt}%
	%
	\pgfpointdiff
		{\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}}
		{\pgfplotspointminmaxmin}%
	\xdef\pgfplotspointyaxis{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	\pgfmathveclen{\pgf@x}{\pgf@y}%
	\xdef\pgfplotspointyaxislength{\pgfmathresult pt}%
	%
	\ifpgfplots@threedim
		\pgfpointdiff
			{\pgfqpoint{\pgfplots@xcoordminTEX}{\pgfplots@ycoordminTEX}}
			{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
		\xdef\pgfplotspointzaxis{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
		\pgfmathveclen{\pgf@x}{\pgf@y}%
		\xdef\pgfplotspointzaxislength{\pgfmathresult pt}%
		%
		\pgfpointscale
			{0.5}%
			{\pgfplotspointxaxis
			\pgf@xa=\pgf@x
			\pgf@xb=\pgf@y
			\pgfplotspointyaxis%
			\advance\pgf@xa by\pgf@x
			\advance\pgf@xb by\pgf@y
			\pgfplotspointzaxis%
			\advance\pgf@xa by\pgf@x
			\advance\pgf@xb by\pgf@y
			\global\pgf@x=\pgf@xa
			\global\pgf@y=\pgf@xb
			}%
		\xdef\pgfplotspointcenter{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	\else
		\global\let\pgfplotspointzaxis=\pgfpointorigin
		\gdef\pgfplotspointzaxislength{0pt}%
		\pgfpointscale
			{0.5}%
			{\pgfpointadd
				\pgfplotspointxaxis%
				\pgfplotspointyaxis%
			}%
		\xdef\pgfplotspointcenter{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	\fi
	\endgroup
}

% This here is a low-weight node. It can ONLY be used during axis
% descriptions and is completely useless otherwise.
%
% See pgfplots@low@level@shape below.
\pgfdeclareshape{pgfplots@low@level@shape@INNER}{%
	\nodeparts{image}%
	\anchor{image}{\pgfpointorigin}%
	%
	%
	\anchor{center}{\pgfplotsqpointdescriptionxy{0.5}{0.5}}%
	\anchor{north}{\pgfplotsqpointdescriptionxy{0.5}{1}}%
	\anchor{north east}{\pgfplotsqpointdescriptionxy{1}{1}}%
	\anchor{east}{\pgfplotsqpointdescriptionxy{1}{0.5}}
	\anchor{south east}{\pgfplotsqpointdescriptionxy{1}{0}}%
	\anchor{south}{\pgfplotsqpointdescriptionxy{0.5}{0}}%
	\anchor{south west}{\pgfplotsqpointdescriptionxy{0}{0}}%
	\anchor{west}{\pgfplotsqpointdescriptionxy{0}{0.5}}%
	\anchor{north west}{\pgfplotsqpointdescriptionxy{0}{1}}%
	%%
	\anchor{origin}{\pgfplotspointaxisorigin}%
	\anchor{above origin}{%
		\pgfpointintersectionoflines
			{\pgfplotspointaxisorigin}
			{\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointyaxis}}
			{\pgfplotsqpointdescriptionxy{0}{1}}
			{\pgfplotsqpointdescriptionxy{1}{1}}%
	}%
	\anchor{left of origin}{%
		\pgfpointintersectionoflines
			{\pgfplotspointaxisorigin}
			{\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}}
			{\pgfplotsqpointdescriptionxy{0}{0}}
			{\pgfplotsqpointdescriptionxy{0}{1}}%
	}%
	\anchor{right of origin}{%
		\pgfpointintersectionoflines
			{\pgfplotspointaxisorigin}
			{\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointxaxis}}
			{\pgfplotsqpointdescriptionxy{1}{0}}
			{\pgfplotsqpointdescriptionxy{1}{1}}%
	}%
	\anchor{below origin}{%
		\pgfpointintersectionoflines
			{\pgfplotspointaxisorigin}
			{\pgfpointadd{\pgfplotspointaxisorigin}{\pgfplotspointyaxis}}
			{\pgfplotsqpointdescriptionxy{0}{0}}
			{\pgfplotsqpointdescriptionxy{1}{0}}%
	}%
	%%
	%%
	%%
	%%
	\anchorborder{}%
	\backgroundpath{}%
	\foregroundpath{}%
	\behindbackgroundpath{}%
	\beforebackgroundpath{}%
	\behindforegroundpath{}%
	\beforeforegroundpath{}%
}

% This is the main axis shape.
%
% It has one node part, which is the complete image. It provides a lot
% of anchors.
\pgfdeclareshape{pgfplots@low@level@shape}{%
	% The '(0,0)' point is the LOWER LEFT OUTER CORNER.
	\savedanchor\upperrightcorner{
		\global\pgf@x=\wd\pgfnodepartimagebox
		\global\pgf@y=\ht\pgfnodepartimagebox
	}%
	\savedanchor\lowerleftinnercorner{%
		\pgfqpoint{\pgfplots@savedanchor@inner@lowerleft@x\relax}{\pgfplots@savedanchor@inner@lowerleft@y\relax}%
	}%
	\savedanchor\innerdiagonal{\pgfplotspointbbdiagonal}%
	\savedanchor\origin{%
		\pgfplotspointaxisorigin
	}%
	%
	\nodeparts{image}%
	\anchor{image}{%
		\global\pgf@x=0pt %
		\global\pgf@y=0pt %
	}%
	%
	%
	\anchor{center}{%
		\pgfpointadd
			{\lowerleftinnercorner}%
			{\pgfpointscale
				{0.5}
				{\innerdiagonal}}%
	}%
	\anchor{north}{%
		\pgfpointadd
			{\lowerleftinnercorner}
			{\innerdiagonal\global\divide\pgf@x by2 }%
	}%
	\anchor{north east}{%
		\pgfpointadd
			\lowerleftinnercorner
			\innerdiagonal
	}%
	\anchor{east}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\divide\pgf@y by2 }%
	}%
	\anchor{south east}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@y=0sp }%
	}%
	\anchor{south}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\divide\pgf@x by2 \global\pgf@y=0sp }%
	}%
	\anchor{south west}{\lowerleftinnercorner}%
	\anchor{west}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@x=0sp \global\divide\pgf@y by2 }%
	}
	\anchor{north west}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@x=0sp }%
	}%
	%%
	\anchor{origin}{%
		\origin
	}%
	\anchor{above origin}{%
		\pgfpointintersectionoflines
			{\origin}
			{\pgfpointadd{\origin}{\innerdiagonal\global\pgf@x=0sp }}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@x=0sp }}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}%
	}%
	\anchor{left of origin}{%
		\pgfpointintersectionoflines
			{\origin}
			{\pgfpointadd{\origin}{\innerdiagonal\global\multiply\pgf@x by-1 \global\pgf@y=0sp }}
			{\lowerleftinnercorner}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@x=0sp }}%
	}%
	\anchor{right of origin}{%
		\pgfpointintersectionoflines
			{\origin}
			{\pgfpointadd{\origin}{\innerdiagonal\global\pgf@y=0sp }}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@y=0sp }}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal}}%
	}%
	\anchor{below origin}{%
		\pgfpointintersectionoflines
			{\origin}
			{\pgfpointadd{\origin}{\innerdiagonal\global\pgf@x=0sp \global\multiply\pgf@y by-1 }}
			{\lowerleftinnercorner}
			{\pgfpointadd{\lowerleftinnercorner}{\innerdiagonal\global\pgf@y=0sp }}%
	}%
	%
	%%
	%
	\anchor{outer north}{%
		\upperrightcorner
		\global\pgf@x=.5\pgf@x
	}%
	\anchor{outer north east}{\upperrightcorner}%
	\anchor{outer east}{%
		\upperrightcorner
		\global\pgf@y=.5\pgf@y
	}%
	\anchor{outer south east}{%
		\upperrightcorner
		\global\pgf@y=0pt
	}%
	\anchor{outer south}{%
		\upperrightcorner
		\global\pgf@x=.5\pgf@x
		\global\pgf@y=0pt
	}%
	\anchor{outer south west}{%
		\global\pgf@x=0pt
		\global\pgf@y=0pt
	}%
	\anchor{outer west}{%
		\upperrightcorner
		\global\pgf@x=0pt
		\global\pgf@y=.5\pgf@y
	}%
	\anchor{outer north west}{%
		\upperrightcorner
		\global\pgf@x=0pt
	}%
	\anchor{outer center}{%
		\upperrightcorner
		\global\pgf@x=.5\pgf@x
		\global\pgf@y=.5\pgf@y
	}%
	%
	%
	%%
	%%
	\anchor{above north}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@y
		\pgfpointadd
			{\lowerleftinnercorner}
			{\innerdiagonal\divide\pgf@x by2 }%
		\global\pgf@y=\pgfutil@tempdima
	}%
	\anchor{above north east}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@y
		\pgfpointadd
			\lowerleftinnercorner
			\innerdiagonal
		\global\pgf@y=\pgfutil@tempdima
	}%
	\anchor{right of north east}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@x
		\pgfpointadd
			\lowerleftinnercorner
			\innerdiagonal
		\global\pgf@x=\pgfutil@tempdima
	}%
	\anchor{right of east}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@x
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\divide\pgf@y by2 }%
		\global\pgf@x=\pgfutil@tempdima
	}%
	\anchor{right of south east}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@x
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@y=0sp }%
		\global\pgf@x=\pgfutil@tempdima
	}%
	\anchor{below south east}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@y=0sp }%
		\global\pgf@y=0pt
	}%
	\anchor{below south}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\divide\pgf@x by2 \global\pgf@y=0sp }%
		\pgf@y=0pt
	}%
	\anchor{below south west}{%
		\lowerleftinnercorner
		\global\pgf@y=0pt
	}%
	\anchor{left of south west}{%
		\lowerleftinnercorner
		\global\pgf@x=0pt
	}%
	\anchor{left of west}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@x=0sp \global\divide\pgf@y by2 }%
		\global\pgf@x=0pt
	}%
	\anchor{left of north west}{%
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@x=0sp }%
		\global\pgf@x=0pt
	}%
	\anchor{above north west}{%
		\upperrightcorner
		\pgfutil@tempdima=\pgf@y
		\pgfpointadd
			\lowerleftinnercorner
			{\innerdiagonal\global\pgf@x=0sp }%
		\global\pgf@y=\pgfutil@tempdima
	}%
	%%
	%%
	\anchorborder{%
		% Call a function that computes a border point. Since this
		% function will modify dimensions like \pgf@x, we must move them to
		% other dimensions.
		\pgfutil@tempdima=\pgf@x
		\pgfutil@tempdimb=\pgf@y
		\pgfpointborderrectangle%
			{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}}%
			{\upperrightcorner}%
	}%
	\backgroundpath{%
		\pgfkeysvalueof{/pgfplots/@backgroundpath@hook/.@cmd}\pgfeov
		\pgfpathrectangle{\pgfpointorigin}{\upperrightcorner}%
	}%
	\foregroundpath{}%
	\behindbackgroundpath{}%
	\beforebackgroundpath{}%
	\behindforegroundpath{}%
	\beforeforegroundpath{}%
}

\def\pgfplots@restore@deprecated@lowlevel@shape{%
	\pgfutil@ifundefined{pgfplots@low@level@shape@deprecated@isdefined}{%
	\gdef\pgfplots@low@level@shape@deprecated@isdefined{1}%
	%
	% all these assignments are global, so it is save to call this
	% macro inside of scopes:
	\pgfdeclareshape{pgfplots@low@level@shape@deprecated}{%
		% The '(0,0)' point is the LOWER LEFT OUTER CORNER.
		\savedanchor\upperrightcorner{
			\global\pgf@x=\wd\pgfnodepartimagebox
			\global\pgf@y=\ht\pgfnodepartimagebox
		}%
		\savedanchor\lowerleftinnercorner{%
			\pgfqpoint{\pgfplots@savedanchor@inner@lowerleft@x\relax}{\pgfplots@savedanchor@inner@lowerleft@y\relax}%
		}%
		\savedanchor\xaxisvec{\pgfplotspointxaxis}%
		\savedanchor\yaxisvec{\pgfplotspointyaxis}%
		\savedanchor\origin{%
			\pgfplotspointaxisorigin
		}%
		%
		\nodeparts{image}%
		\anchor{image}{%
			\global\pgf@x=0pt %
			\global\pgf@y=0pt %
		}%
		%
		%
		\anchor{center}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointscale{0.5}{\pgfpointadd{\xaxisvec}{\yaxisvec}}}%
		}%
		\anchor{north}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}%
		}%
		\anchor{north east}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\yaxisvec}{\xaxisvec}}%
		}%
		\anchor{east}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}%
		}%
		\anchor{south east}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\xaxisvec}%
		}%
		\anchor{south}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointscale{0.5}{\xaxisvec}}%
		}%
		\anchor{south west}{\lowerleftinnercorner}%
		\anchor{west}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointscale{0.5}{\yaxisvec}}%
		}%
		\anchor{north west}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\yaxisvec}%
		}%
		%%
		\anchor{origin}{%
			\origin
		}%
		\anchor{above origin}{%
			\pgfpointintersectionoflines
				{\origin}
				{\pgfpointadd{\origin}{\yaxisvec}}
				{\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}
				{\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}{\xaxisvec}}%
		}%
		\anchor{left of origin}{%
			\pgfpointintersectionoflines
				{\origin}
				{\pgfpointadd{\origin}{\pgfpointscale{-1}{\xaxisvec}}}
				{\lowerleftinnercorner}
				{\pgfpointadd{\lowerleftinnercorner}{\yaxisvec}}%
		}%
		\anchor{right of origin}{%
			\pgfpointintersectionoflines
				{\origin}
				{\pgfpointadd{\origin}{\xaxisvec}}
				{\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}
				{\pgfpointadd{\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}{\yaxisvec}}%
		}%
		\anchor{below origin}{%
			\pgfpointintersectionoflines
				{\origin}
				{\pgfpointadd{\origin}{\pgfpointscale{-1}{\yaxisvec}}}
				{\lowerleftinnercorner}
				{\pgfpointadd{\lowerleftinnercorner}{\xaxisvec}}%
		}%
		%
		%%
		%
		\anchor{outer north}{%
			\upperrightcorner
			\global\pgf@x=.5\pgf@x
		}%
		\anchor{outer north east}{\upperrightcorner}%
		\anchor{outer east}{%
			\upperrightcorner
			\global\pgf@y=.5\pgf@y
		}%
		\anchor{outer south east}{%
			\upperrightcorner
			\global\pgf@y=0pt
		}%
		\anchor{outer south}{%
			\upperrightcorner
			\global\pgf@x=.5\pgf@x
			\global\pgf@y=0pt
		}%
		\anchor{outer south west}{%
			\global\pgf@x=0pt
			\global\pgf@y=0pt
		}%
		\anchor{outer west}{%
			\upperrightcorner
			\global\pgf@x=0pt
			\global\pgf@y=.5\pgf@y
		}%
		\anchor{outer north west}{%
			\upperrightcorner
			\global\pgf@x=0pt
		}%
		\anchor{outer center}{%
			\upperrightcorner
			\global\pgf@x=.5\pgf@x
			\global\pgf@y=.5\pgf@y
		}%
		%
		%
		%%
		%%
		\anchor{above north}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@y
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\yaxisvec}{\pgfpointscale{0.5}{\xaxisvec}}}%
			\global\pgf@y=\pgfutil@tempdima
		}%
		\anchor{above north east}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@y
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\yaxisvec}{\xaxisvec}}%
			\global\pgf@y=\pgfutil@tempdima
		}%
		\anchor{right of north east}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@x
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\yaxisvec}{\xaxisvec}}%
			\global\pgf@x=\pgfutil@tempdima
		}%
		\anchor{right of east}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@x
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointadd{\xaxisvec}{\pgfpointscale{0.5}{\yaxisvec}}}%
			\global\pgf@x=\pgfutil@tempdima
		}%
		\anchor{right of south east}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@x
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\xaxisvec}%
			\global\pgf@x=\pgfutil@tempdima
		}%
		\anchor{below south east}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\xaxisvec}%
			\global\pgf@y=0pt
		}%
		\anchor{below south}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointscale{0.5}{\xaxisvec}}%
			\global\pgf@y=0pt
		}%
		\anchor{below south west}{%
			\lowerleftinnercorner
			\global\pgf@y=0pt
		}%
		\anchor{left of south west}{%
			\lowerleftinnercorner
			\global\pgf@x=0pt
		}%
		\anchor{left of west}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\pgfpointscale{0.5}{\yaxisvec}}%
			\global\pgf@x=0pt
		}%
		\anchor{left of north west}{%
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\yaxisvec}%
			\global\pgf@x=0pt
		}%
		\anchor{above north west}{%
			\upperrightcorner
			\pgfutil@tempdima=\pgf@y
			\pgfpointadd
				{\lowerleftinnercorner}%
				{\yaxisvec}%
			\global\pgf@y=\pgfutil@tempdima
		}%
		%%
		%%
		\anchorborder{%
			% Call a function that computes a border point. Since this
			% function will modify dimensions like \pgf@x, we must move them to
			% other dimensions.
			\pgfutil@tempdima=\pgf@x
			\pgfutil@tempdimb=\pgf@y
			\pgfpointborderrectangle%
				{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdimb}}%
				{\upperrightcorner}%
		}%
		\backgroundpath{%
			\pgfkeysvalueof{/pgfplots/@backgroundpath@hook/.@cmd}\pgfeov
			\pgfpathrectangle{\pgfpointorigin}{\upperrightcorner}%
		}%
		\foregroundpath{}%
		\behindbackgroundpath{}%
		\beforebackgroundpath{}%
		\behindforegroundpath{}%
		\beforeforegroundpath{}%
	}%
	}{}%
}%

% A command which has to be invoked BEFORE \pgfplots@draw@axis to
% prepare everything.
\def\pgfplots@draw@axis@pre{%
	% Preparation for axis lines and discontinuities:
	\pgfplots@drawaxis@lines@preparediscont@for{x}%
	\pgfplots@drawaxis@lines@preparediscont@for{y}%
	\ifpgfplots@threedim
		\pgfplots@drawaxis@lines@preparediscont@for{z}%
	\fi
	\ifpgfplots@threedim
		\pgfplots@separate@axis@linestrue
	\else
		\if\pgfplots@xaxislinesnum0\else
			\pgfplots@separate@axis@linestrue
		\fi
		\if\pgfplots@yaxislinesnum0\else
			\pgfplots@separate@axis@linestrue
		\fi
	\fi
	% compute tick position lists
	% 	\pgfplots@prepared@tick@positions@minor@x
	% and
	% 	\pgfplots@prepared@tick@positions@major@x
	\ifpgfplots@hide@x\else
		\expandafter\pgfplots@prepare@tick@coordlists@for\expandafter x\expandafter{\pgfplots@xtick}%
	\fi
	\ifpgfplots@hide@y\else
		\expandafter\pgfplots@prepare@tick@coordlists@for\expandafter y\expandafter{\pgfplots@ytick}%
	\fi
	\ifpgfplots@threedim
		\ifpgfplots@hide@z\else
			\expandafter\pgfplots@prepare@tick@coordlists@for\expandafter z\expandafter{\pgfplots@ztick}%
		\fi
	\fi
}

% PRECONDITION:
% 	\pgfplots@draw@axis@pre has been called.
\def\pgfplots@draw@axis{%
	%
	%
	%
%\message{Ok, I am now in pgfplots@draw@axis; ready to do work. Hide flags: hide x = \ifpgfplots@hide@x true\else false\fi; hide y = \ifpgfplots@hide@y true\else false\fi hide z = \ifpgfplots@hide@z true \else false \fi. Vector length: x = \pgfplots@x@veclength (1/x = \pgfplots@x@inverseveclength). y = \pgfplots@y@veclength (1/y = \pgfplots@y@inverseveclength) z = \pgfplots@z@veclength (1/z = \pgfplots@z@inverseveclength)}%
	\ifpgfplots@threedim
%\if10
		\if2\pgfplots@zaxislinesnum
			% axis z line*=center
			\pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@logical@ZERO@z}{2}%
			\pgfplots@draw@axis@insurface@symmetric xyz
		\else
			% the other cases are handled in
			% \pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn
			\pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}%
			\pgfplots@draw@axis@insurface@symmetric xyz
			%
			\pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}%
			\pgfplots@draw@axis@insurface@symmetric xyz
		\fi
		%
%\fi\if10
		\if2\pgfplots@xaxislinesnum
			% axis x line*=center
			\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@logical@ZERO@x}{2}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid yzx
			\pgfplots@draw@axis@insurface zyx
		\else
			\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid yzx
			\pgfplots@draw@axis@insurface zyx
			%
			\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid yzx
			\pgfplots@draw@axis@insurface zyx
		\fi
%\fi\if10
		%
		\if2\pgfplots@yaxislinesnum
			\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@logical@ZERO@y}{2}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid xzy
			\pgfplots@draw@axis@insurface@onlyticksandgrid zxy
		\else
			\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid xzy
			\pgfplots@draw@axis@insurface@onlyticksandgrid zxy
			%
			\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymax}{1}%
			\pgfplots@draw@axis@insurface@onlyticksandgrid xzy
			\pgfplots@draw@axis@insurface@onlyticksandgrid zxy
		\fi
%\fi
	\else
		% Just use the 2d-point commands (assuming Z=0)
		\let\pgfplotspointonorientedsurfaceabsetupforxyz=\pgfplotspointonorientedsurfaceabsetupforxy
		\let\pgfplotspointonorientedsurfaceabsetupforyxz=\pgfplotspointonorientedsurfaceabsetupforyx
		\pgfplots@draw@axis@insurface@symmetric xyz
	\fi
}%

% The complement of \pgfplots@draw@axis which will ALWAYS be drawn on
% top of every thing else; it complements the rest.
%
% This implements only the 3d box=complete feature.
%
% PRECONDITION:
% 	\pgfplots@draw@axis@pre has been called.
\def\pgfplots@draw@axis@post{%
	\ifpgfplots@threedim
		\if0\pgfplots@threedimbox@choice
			% 3d box=background
		\else
			\if0\pgfplots@xaxislinesnum
			\else
				\def\pgfplots@threedimbox@choice{0}%
			\fi
			\if0\pgfplots@yaxislinesnum
			\else
				\def\pgfplots@threedimbox@choice{0}%
			\fi
			\if0\pgfplots@zaxislinesnum
			\else
				\def\pgfplots@threedimbox@choice{0}%
			\fi
			\if\pgfplots@threedimbox@choice0%
				\pgfplots@error{Sorry, your choice for '3d box' and 'axis x line' is incompatible.}%
			\else
				% 3d box=complete or complete*
				\begingroup
				\pgfplotsset{every 3d box foreground}%
				\let\pgfplots@drawticklabels@onorientedsurf=\relax
				\if2\pgfplots@threedimbox@choice
					\def\pgfplots@ifgridlines@onorientedsurf@should@be@drawn##1##2{%
						##1%
					}%
				\else
					\let\pgfplots@drawgridlines@onorientedsurf=\relax
				\fi
				%
				\let\pgfplots@drawticklabels@onorientedsurf=\relax
				%
				% negate the meaning of this if:
				\let\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@@ORIG=\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@%
				\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{%
					\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@@ORIG{##1}{##3}{##2}%
				}%
				%
				% the following code is *almost* the same as if we would
				% have called
				% \pgfplots@draw@axis again.
				% The difference is in the
				% \pgfplotsifaxissurfaceisforeground checks. 
				% Furthermore, I have removed the case distinctions for
				% the different axis line combinations.
	%\if10
				% axis z line*=box
				%
				\pgfplotsifaxissurfaceisforeground{vv0}{%
					\pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmin}{0}%
					\pgfplots@draw@axis@insurface@symmetric xyz
				}{}%
				%
				\pgfplotsifaxissurfaceisforeground{vv1}{%
					\pgfplotspointonorientedsurfaceabsetupforsetz{\pgfplots@zmax}{1}%
					\pgfplots@draw@axis@insurface@symmetric xyz
				}{}%
				%
	%\fi\if10
				% axis x line*=box
				\pgfplotsifaxissurfaceisforeground{0vv}{%
					\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmin}{0}%
					\pgfplots@draw@axis@insurface@onlyticksandgrid yzx
					\pgfplots@draw@axis@insurface zyx
				}{}
				%
				\pgfplotsifaxissurfaceisforeground{1vv}{%
					\pgfplotspointonorientedsurfaceabsetupforsetx{\pgfplots@xmax}{1}%
					\pgfplots@draw@axis@insurface@onlyticksandgrid yzx
					\pgfplots@draw@axis@insurface zyx
				}{}
	%\fi\if11
				%
				\pgfplotsifaxissurfaceisforeground{v0v}{%
					\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymin}{0}%
					\pgfplots@draw@axis@insurface@onlyticksandgrid xzy
					\pgfplots@draw@axis@insurface@onlyticksandgrid zxy
				}{}%
				%
				\pgfplotsifaxissurfaceisforeground{v1v}{%
					\pgfplotspointonorientedsurfaceabsetupforsety{\pgfplots@ymax}{1}%
					\pgfplots@draw@axis@insurface@onlyticksandgrid xzy
					\pgfplots@draw@axis@insurface@onlyticksandgrid zxy
				}{}%
	%\fi
				\endgroup
				% end of 3d box=complete
			\fi
		\fi
	\fi
}%

\def\pgfplots@define@threedim@marks{%
	\ifpgfplots@threedim
		% FIXME : there is always the same arithmetics going on here. I could try to optimize it -- for fixed mark size.
		\pgfdeclareplotmark{cube}
		{%
			\pgfplots@cube@gethalf@x
			\let\pgfplots@cube@halfx=\pgfmathresult
			\pgfplots@cube@gethalf@y
			\let\pgfplots@cube@halfy=\pgfmathresult
			\pgfplots@cube@gethalf@z
			\let\pgfplots@cube@halfz=\pgfmathresult
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathclose
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathclose
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
			%
			\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
			\pgfusepathqstroke
			%
		}%
		\pgfdeclareplotmark{cube*}
		{%
			\pgfplots@cube@gethalf@x
			\let\pgfplots@cube@halfx=\pgfmathresult
			\pgfplots@cube@gethalf@y
			\let\pgfplots@cube@halfy=\pgfmathresult
			\pgfplots@cube@gethalf@z
			\let\pgfplots@cube@halfz=\pgfmathresult
			%
			\pgfplotsifaxissurfaceisforeground{0vv}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}%
			\pgfplotsifaxissurfaceisforeground{v0v}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}%
			\pgfplotsifaxissurfaceisforeground{vv0}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{-\pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}{%
				\pgfpathmoveto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{-\pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{ \pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathlineto{\pgfplotsqpointxyz{ \pgfplots@cube@halfx}{-\pgfplots@cube@halfy}{ \pgfplots@cube@halfz}}%
				\pgfpathclose
				\pgfusepathqfillstroke
			}%
		}%
	\else
		\pgfdeclareplotmark{cube}{\pgfuseplotmark{square}}%
		\pgfdeclareplotmark{cube*}{\pgfuseplotmark{square*}}%
	\fi
}

% Defines booleans for every surface of the axis cube indicating
% whether they shall be drawn or not.
%
% For 2D, the only available surface is 'vv0' (x=varying; y=varying; z=zmin)
% For 3D, there are surfaces
% 	- 'vv0' 'vv1'
% 	- 'v0v' 'v1v'
% 	' '0vv' '1vv'
% 
% @see \pgfplotspointonorientedsurfaceabmatchaxisline for details
% about those three-character ids.
%
% @PRECONDITION
%
% @POSTCONDITION
%   - for every available surface, a macro '\pgfplots@surfviewdepth@CCC'
%   is defined to be either 'f' (foreground) or 'b' (background).
%   Thus, we don't have real TeX booleans, "only" those one-character
%   strings.
%   There are high-level routines to check these flags.
%   - every tick label position will be initialised, i.e. the macros
%   	\pgfplots@[xyz]ticklabelaxisspec
%     will be initialised.
%
% ABOUT THE ALGORITHM:
% Given \pgfplots@view@dir@threedim@[xyz], we know the view direction (in 3D!).
% Now, we compute the scalar products <n,(1,0,0)'>  <n,(0,1,0)'> and
% <n,(0,0,1)'> between the view direction n and the unit vectors in 3D
% space. Of course, these scalar products are just specific components
% of n. Using the sign of the scalar product, we know whether n points
% roughly into the same or the opposite direction of each unit vector
% and we can deduce foreground and background side surfaces of the
% unit cube. The idea is: foreground surfaces won't be drawn, only
% background surfaces.
%
% Given this knowledge, we can also deduce the default axes for tick
% labels.
%
% The operation is relatively fast.
\def\pgfplots@decide@which@figure@surfaces@are@drawn{%
	\expandafter\def\csname pgfplots@surfviewdepth@2vv\endcsname{f}% 
	\expandafter\def\csname pgfplots@surfviewdepth@v2v\endcsname{f}% 
	\expandafter\def\csname pgfplots@surfviewdepth@vv2\endcsname{f}% 
	\ifpgfplots@threedim
		% respect reversed axes here. If I am not mistaken, it should
		% be completely sufficient to flip signs here:
		\ifdim\pgfplots@view@dir@threedim@x pt\if\pgfkeysvalueof{/pgfplots/x dir/value}n>\else<\fi0pt
			\expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{f}% foreground
			\expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{b}% background
		\else
			\expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}% 
			\expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}% 
		\fi
		\ifdim\pgfplots@view@dir@threedim@y pt\if\pgfkeysvalueof{/pgfplots/y dir/value}n>\else<\fi0pt
			\expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{f}% foreground
			\expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{b}% background
		\else
			\expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}% 
			\expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}% 
		\fi
		\ifdim\pgfplots@view@dir@threedim@z pt\if\pgfkeysvalueof{/pgfplots/z dir/value}n>\else<\fi0pt
			\expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{f}% foreground
			\expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{b}% background
		\else
			\expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% 
			\expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% 
		\fi
		%
		%
		% Now, determine which axis line shall get tick labels.
		% The strategie is as follows:
		% - only lines on the convex hull of the 2D projected axis
		%   rectangle can get tick labels,
		% - for each axis, there are two such choices in the general
		%   case,
		% - for X and Y: prefer the one on the lower side.
		% - for Z: prefer the one on the left hand side.
		%
		\pgfplotspointcenter
		\edef\pgfplots@tmp@centerx{\the\pgf@x}%
		\edef\pgfplots@tmp@centery{\the\pgf@y}%
		%
		\pgfplots@init@ticklabelaxisspecfor xy%
		%
		\pgfplots@init@ticklabelaxisspecfor yy%
		%
		\pgfplots@init@ticklabelaxisspecfor zx%
	\else
		% FIXME : it might be better to implement that stuff here
		% implicilty using the 3D algorithms.
		%
		% this here is the only important one:
		\expandafter\def\csname pgfplots@surfviewdepth@vv0\endcsname{b}% 
		%
		\expandafter\def\csname pgfplots@surfviewdepth@0vv\endcsname{b}% 
		\expandafter\def\csname pgfplots@surfviewdepth@1vv\endcsname{f}% 
		\expandafter\def\csname pgfplots@surfviewdepth@v0v\endcsname{b}% 
		\expandafter\def\csname pgfplots@surfviewdepth@v1v\endcsname{f}% 
		\expandafter\def\csname pgfplots@surfviewdepth@vv1\endcsname{f}% 
		\def\pgfplotsifaxislineisonconvexhull##1##2##3{##2}% ALWAYS TRUE
		\def\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn@##1##2##3{##2}% ALWAYS TRUE
		%
		\pgfplotspointcenter
		\edef\pgfplots@tmp@centerx{\the\pgf@x}%
		\edef\pgfplots@tmp@centery{\the\pgf@y}%
		%
		\pgfplots@init@ticklabelaxisspec@twodim@for xy%
		%
		\pgfplots@init@ticklabelaxisspec@twodim@for yx%
	\fi
}

% A helper method which is to be invoked ONLY inside of
% \pgfplots@decide@which@figure@surfaces@are@drawn.
% It does NOT work outside of it.
%
% It initialises the 'pgfplots@#1ticklabelaxisspec' macro according to
% the foreground/background situation of the axis and the '#1ticklabel pos' 
% key.
%
% #1: the axis: x,y or z
% #2: either x or y. It refers to the PROJECTED coordinate which
% should be used to compare the 'lower' and 'upper' arguments of the 
% |[xyz]ticklabel pos| key.
%  
% PRECONDITION:
% 	\pgfplots@tmp@center[xy] is set.
%
% POSTCONDITION:
% 	- pgfplots@#1ticklabelaxisspec is set,
%	- pgfplots@#1ticklabel@suggested@anchor is set
%
% @see also \pgfplots@init@ticklabelaxisspec@twodim@for
\def\pgfplots@init@ticklabelaxisspecfor#1#2{%
	\if#1x%
		\def\pgfplots@loc@to@threedim##1##2{v##1##2}%
		\def\pgfplots@loc@axischar@for@first{y}%
	\else
		\if#1y%
			\def\pgfplots@loc@to@threedim##1##2{##1v##2}%
			\def\pgfplots@loc@axischar@for@first{x}%
		\else
			\def\pgfplots@loc@to@threedim##1##2{##1##2v}%
			\def\pgfplots@loc@axischar@for@first{x}%
		\fi
	\fi
	\pgfplotsifaxislineisonconvexhull{\pgfplots@loc@to@threedim 00}{%
		% -> both, v00 or v11 are on CH.
		%
		% Decide whether the '{0.5}{0}{0}' point is above or below
		% the {0.5}{0.5}{0.5}
		% point. This '<' operation is based on the '#1ticklabel pos'
		% key, the 2D projection of the axis and the argument '#2'.
		\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 00}%
		\pgfqpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}%
		\ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax
			\if u\csname pgfplots@#1ticklabel@pos\endcsname
				\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 11}%
			\fi
		\else
			\if l\csname pgfplots@#1ticklabel@pos\endcsname
				\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 11}%
			\fi
		\fi
	}{%
		% -> both, v01 or v10 are on CH
		%--------------------------------------------------
		% \pgfplotsifaxislineisonconvexhull{\pgfplots@loc@to@threedim 01}{% FIXME : eliminate sanity assertion if possible
		% }{%
		% 	\pgfplots@error{INTERNAL ERROR}%
		% }%
		%-------------------------------------------------- 
		% Decide whether the '{0.5}{1}{0}' point is above or below
		% the {0.5}{0.5}{0.5} point. Again, the '<' operation is based
		% on the '#1ticklabel pos' key, the projection and #2.
		\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 10}%
		% compute the middle point on \pgfplots@loc@to@threedim 10
		\pgfpointadd
			{\csname pgfplotspoint\pgfplots@loc@axischar@for@first axis\endcsname}
			{\pgfpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}}%
		%
		\ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax
			\if u\csname pgfplots@#1ticklabel@pos\endcsname
				\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 01}%
			\fi
		\else
			\if l\csname pgfplots@#1ticklabel@pos\endcsname
				\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 01}%
			\fi
		\fi
	}%
}%
\def\pgfplots@init@ticklabelaxisspec@twodim@for#1#2{%
	\if#1x%
		\def\pgfplots@loc@to@threedim##1{v##10}%
		\def\pgfplots@loc@axischar@for@first{y}%
	\else
		\def\pgfplots@loc@to@threedim##1{##1v0}%
		\def\pgfplots@loc@axischar@for@first{x}%
	\fi
	% Decide whether the '{0.5}{0}' point is above or below
	% the {0.5}{0.5}
	% point. This '<' operation is based on the '#1ticklabel pos'
	% key, the 2D projection of the axis and the argument '#2'.
	\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 0}%
	\pgfqpointscale{0.5}{\csname pgfplotspoint#1axis\endcsname}%
	\ifdim\csname pgf@#2\endcsname<\csname pgfplots@tmp@center#2\endcsname\relax
		\if u\csname pgfplots@#1ticklabel@pos\endcsname
			\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 1}%
		\fi
	\else
		%--------------------------------------------------
		%FIXME : I have the impression that this here is DEPRECATED
		% \if3\csname pgfplots@#1tickposnum\endcsname % is 'right'
		% 	\expandafter\def\csname pgfplots@#1tickposnum\endcsname{1}% set to 'left'
		% \else
		% 	\if1\csname pgfplots@#1tickposnum\endcsname % is 'left'
		% 		\expandafter\def\csname pgfplots@#1tickposnum\endcsname{3}% set to 'right'
		% 	\fi
		% \fi
		%-------------------------------------------------- 
		\if l\csname pgfplots@#1ticklabel@pos\endcsname
			\expandafter\edef\csname pgfplots@#1ticklabelaxisspec\endcsname{\pgfplots@loc@to@threedim 1}%
		\fi
	\fi
}%


% Processes every tick mark in direction #1 and draws tick lines, tick
% labels, grid lines, axis lines and extra ticks.
% 
% #1 : the direction into which tick positions are processed.
% #2 : the direction in which tick lines and grid lines shall be drawn.
% #3 : the direction which is currently fixed.
\def\pgfplots@draw@axis@insurface#1#2#3{%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
		\pgfplots@drawgridlines@onorientedsurf
		%
		\pgfplots@drawticklines@onorientedsurf
		%
		\pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2%
		\pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3%
		%
		\pgfplots@drawticklabels@onorientedsurf
		%
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
			\expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
		\fi
	}%
}%

% A variant of \pgfplots@draw@axis@insurface which is equivalent to
% \pgfplots@draw@axis@insurface #1#2#3
% \pgfplots@draw@axis@insurface #2#1#3
% with slightly optimized execution sequence.
\def\pgfplots@draw@axis@insurface@symmetric#1#2#3{%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
		\pgfplots@drawgridlines@onorientedsurf
	}%
	\pgfplots@if{pgfplots@hide@#2}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname
		\pgfplots@drawgridlines@onorientedsurf
	}%
	%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
		\pgfplots@drawticklines@onorientedsurf
	}%
	\pgfplots@if{pgfplots@hide@#2}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname
		\pgfplots@drawticklines@onorientedsurf
	}%
	%
	\ifpgfplots@separate@axis@lines
		\pgfplots@if{pgfplots@hide@#1}{\relax}{%
			\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
			\pgfplots@drawaxis@outerlines@separate@onorientedsurf#1#2%
			\pgfplots@drawaxis@innerlines@onorientedsurf#1#2#3%
		}%
		%
		\pgfplots@if{pgfplots@hide@#2}{\relax}{%
			\csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname
			\pgfplots@drawaxis@outerlines@separate@onorientedsurf#2#1%
			\pgfplots@drawaxis@innerlines@onorientedsurf#2#1#3%
		}%
	\else
		% this happens if and only if d=2 and the axis lines are drawn
		% as box.
		\pgfplots@drawaxis@outerlines@cycledpath
	\fi
	%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
		\pgfplots@drawticklabels@onorientedsurf
	}%
	\pgfplots@if{pgfplots@hide@#2}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname
		\pgfplots@drawticklabels@onorientedsurf
	}%
	%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
			\expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
		\fi
	}%
	\pgfplots@if{pgfplots@hide@#2}{\relax}{%
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#2tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\csname pgfplotspointonorientedsurfaceabsetupfor#2#1#3\endcsname
			\expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
		\fi
	}%
}%

\def\pgfplots@draw@axis@insurface@onlyticksandgrid#1#2#3{%
	\pgfplots@if{pgfplots@hide@#1}{\relax}{%
		\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
		\pgfplots@drawgridlines@onorientedsurf
		\pgfplots@drawticklines@onorientedsurf
		%
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\begingroup
			\let\pgfplots@drawticklabels@onorientedsurf=\relax
			\csname pgfplotspointonorientedsurfaceabsetupfor#1#2#3\endcsname
			\expandafter\pgfplots@draw@extra@ticks@onorientedsurf\expandafter{\pgfplots@loc@TMPa}%
			\endgroup
		\fi
	}%
}%

% Handles the 'every 3d description' style.
%
% This requires a different type of attention than any other key --
% because all other keys are set in a context where the dimension of
% the axis is unknown (it might be 2 or 3 dimensional).
%
% The idea is:
% Call \pgfplots@BEGIN@prepare@description@styles as soon as the
% dimension is fixed, but before any style changes of the user
% interface are applied.
%
% Example:
% \begin{axis}[xlabel style={}]
% will be processed here. The reason: 'every 3d description' will
% certainly use a different style for axis labels than the default 2d
% style.
%
% Thus, all style changes which are relevant for 'every 3d description' 
% have NOT YET been processed (they have been appended to 'every axis').
\def\pgfplots@BEGIN@prepare@description@styles{%
	\ifpgfplots@threedim
		\pgfplotsset{every 3d description,every 3d view {\pgfkeysvalueof{/pgfplots/view/az}}{\pgfkeysvalueof{/pgfplots/view/el}}/.try}%
	\fi
	\pgfkeysgetvalue{/pgfplots/.unknown/.@cmd}\pgfplots@BEGIN@prepare@description@styles@oldhandler
	\pgfkeysdef{/pgfplots/.unknown}{}% ignore unknown keys here.
	\pgfkeysactivatefamily{/pgfplots/style commands}%
	\pgfkeysactivatefamily{/pgfplots/descriptions}%
%\pgfkeys{/pgfplots/every axis/.show code}%
	\pgfplots@set@keys@from@tikz@style{every axis}%
	\pgfkeysdeactivatefamily{/pgfplots/descriptions}%
	\pgfkeysdeactivatefamily{/pgfplots/style commands}%
	\pgfkeyslet{/pgfplots/.unknown/.@cmd}\pgfplots@BEGIN@prepare@description@styles@oldhandler
}%

\def\pgfplots@BEGIN@init@and@draw@axis{%
	\pgfplots@determinedefaultvalues
	\setbox\pgfnodepartimagebox=\hbox\bgroup\bgroup
		\pgfinterruptpicture
		\tikzpicture[/pgfplots/every axis]%
		% set baseline for sub-picture to default value.
		% the baseline option will be applied to the OUTER picture.
		\pgfsetbaseline{\pgf@picminy}%
		\pgfutil@ifundefined{pgfsettrimleft}{}{%
			\pgfsettrimleft{\pgf@picminx}%
			\pgfsettrimright{\pgf@picmaxx}%
		}%
		\begingroup
			\pgfgettransformentries\aa\ab\ba\bb\pgfplots@loc@TMPa\pgfplots@loc@TMPb
			\xdef\pgfplots@savedtransformshift{%
				\global\pgf@x=\pgfplots@loc@TMPa\space
				\global\pgf@y=\pgfplots@loc@TMPb\space
			}%
			\xdef\pgfplots@glob@TMPa{{\aa}{\ab}{\ba}{\bb}}%
		\endgroup
		\expandafter\pgfsettransformentries\pgfplots@glob@TMPa{0pt}{0pt}%
		%
		\pgfplots@draw@axis@pre
		\scope
		%
		\pgfkeysifdefined{/pgfplots/axis background/.@cmd}{%
			\path[/pgfplots/axis background] \pgfextra{\pgfplots@clippath@install{}};%
		}{}%
		%
		\ifpgfplots@axis@on@top
		\else
			\pgfplots@draw@axis
		\fi
		% CLIPPING:
		\ifpgfplots@clip
			\pgfplots@clippath@install{\pgfusepath{clip}}%
		\fi
		\pgfplotspointbb@assertvaluesexist%
}

% Defines \pgfplots@clippath@install.
% @PRECONDITION  the axis limits must be ready.
\def\pgfplots@clippath@prepare{%
	\def\pgfplots@clippath@use@##1{%
		\ifx\pgfplotspoint@bb@@@\relax
			% remember the axis dimensions as well:
			\ifdim\pgf@pathmaxx=-16000pt
			\else
				\begingroup
				\pgf@xa=\pgf@pathmaxx
				\advance\pgf@xa by-\pgf@pathminx
				\pgf@ya=\pgf@pathmaxy
				\advance\pgf@ya by-\pgf@pathminy
				\xdef\pgfplots@glob@TMPa{{\the\pgf@pathminx}{\the\pgf@pathminy}{\the\pgf@xa}{\the\pgf@ya}}%
				\endgroup
				\global\let\pgfplotspoint@bb@@@=\pgfplots@glob@TMPa
			\fi
		\fi
		##1%
	}%
	\ifpgfplots@threedim
		% FIXME : this can't be done in three dimensions. :-(
		% -> for 3d, I need to clip at least the 2d projection.
		%
		% -> Identify the convex hull of the 2D projection:
		\pgfplotsifaxissurfaceisforeground{0vv}{%
			\pgfplotsifaxissurfaceisforeground{v0v}{%
				\pgfplotsifaxissurfaceisforeground{vv0}{%
					% ok. Do NOT use the intersection lines
					% - 00v
					% - 0v0
					% - v00
					% so, use 
					%    010 (01v) 011
					%    011 (0v1) 001
					%    001 (v01) 101
					%    101 (10v) 100
					%    100 (1v0) 110 
					%    110 (v10) 011 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}{%
					% foreground surfs: 0vv, v0v, vv1
					%
					% ok. Do NOT use the intersection lines
					% - 00v
					% - 0v1
					% - v01
					% so, use 
					%    010 (01v) 011
					%    011 (v11) 111   
					%    111 (1v1) 101 
					%    101 (10v) 100
					%    100 (v00) 000
					%    000 (0v0) 010 (cycle)
					\def\pgfplots@clippath@install##1{\relax%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}%
			}{%
				\pgfplotsifaxissurfaceisforeground{vv0}{%
					% foreground surfs: 0vv, v1v, vv0
					%
					% ok. Do NOT use the intersection lines
					% - 01v
					% - 0v0
					% - v10
					% so, use
					%   000  (00v) 001   
					%   001  (0v1) 011   
					%   011  (v11) 111   
					%   111  (11v) 110   
					%   110  (1v0) 100   
					%   100  (v00) 000 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}{%
					% foreground surfs: 0vv, v1v, vv1
					%
					% ok. Do NOT use the intersection lines
					% - 01v
					% - 0v1
					% - v11
					% so, use
					%   000  (00v) 001   
					%   001  (v01) 101   
					%   101  (1v1) 111   
					%   111  (11v) 110   
					%   110  (v10) 010   
					%   010  (0v0) 000 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}%
			}%
		}{%
			\pgfplotsifaxissurfaceisforeground{v0v}{%
				\pgfplotsifaxissurfaceisforeground{vv0}{%
					% foreground surfs: 1vv, v0v, vv0.
					%
					% Thus: DON'T use the intersection lines
					% - 10v
					% - 1v0
					% - v00
					% So, use
					%   110 (11v) 111   
					%   111 (1v1) 101   
					%   101 (v01) 001   
					%   001 (00v) 000   
					%   000 (0v0) 010   
					%   010 (v10) 110 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}{%
					% foreground surfs: 1vv, v0v, vv1
					% Thus: DON'T use the intersection lines
					% - 10v
					% - 1v1
					% - v01
					% So, use
					%   110 (11v) 111   
					%   111 (v11) 011   
					%   011 (0v1) 001   
					%   001 (00v) 000   
					%   000 (v00) 100   
					%   100 (1v0) 110 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}%
			}{%
				\pgfplotsifaxissurfaceisforeground{vv0}{%
					% foreground surfs: 1vv, v1v, vv0
					% Thus: DON'T use the intersection lines
					% - 11v
					% - 1v0
					% - v10
					% So, use
					%   100 (10v) 101   
					%   101 (1v1) 111   
					%   111 (v11) 011   
					%   011 (01v) 010   
					%   010 (0v0) 000   
					%   000 (v00) 100 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}{%
					% foreground surfs: 1vv, v1v, vv1
					% Thus: DON'T use the intersection lines
					% - 11v
					% - 1v1
					% - v11
					% So, use
					%   100 (10v) 101   
					%   101 (v01) 001   
					%   001 (0v1) 011   
					%   011 (01v) 010   
					%   010 (v10) 110   
					%   110 (1v0) 100 (cycle)
					\def\pgfplots@clippath@install##1{%
						\pgfpathmoveto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymin}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmax}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmin}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathlineto{\pgfplotsqpointxyz{\pgfplots@xmax}{\pgfplots@ymax}{\pgfplots@zmin}}%
						\pgfpathclose
						\pgfplots@clippath@use@{##1}%
					}%
				}%
			}%
		}%
				
	\else
		\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}%
		\edef\pgfplots@loc@TMPa{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
		\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}%
		\edef\pgfplots@loc@TMPb{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
		\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
		\edef\pgfplots@loc@TMPc{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
		\pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymax}%
		\edef\pgfplots@loc@TMPd{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
		\begingroup
		\toks0=\expandafter{\pgfplots@loc@TMPa}%
		\toks1=\expandafter{\pgfplots@loc@TMPb}%
		\toks2=\expandafter{\pgfplots@loc@TMPc}%
		\toks3=\expandafter{\pgfplots@loc@TMPd}%
		\xdef\pgfplots@glob@TMPa##1{%
			\noexpand\pgfpathmoveto{\the\toks0 }%
			\noexpand\pgfpathlineto{\the\toks1 }%
			\noexpand\pgfpathlineto{\the\toks2 }%
			\noexpand\pgfpathlineto{\the\toks3 }%
			\noexpand\pgfplots@clippath@use@{##1}%
		}%
		\endgroup
		\let\pgfplots@clippath@install=\pgfplots@glob@TMPa
	\fi
	% FIXME : workaround clear path sizes at beginning! This shouldn't 
	% be necessary!
	\expandafter\def
	\expandafter\pgfplots@clippath@install
	\expandafter##%
	\expandafter1%
	\expandafter{%
	\expandafter\pgf@resetpathsizes
		\pgfplots@clippath@install{##1}%
	}%
	\global\let\pgfplotspoint@bb@@@=\relax
}%
\def\pgfplotspointbb@assertvaluesexist{%
	\ifx\pgfplotspoint@bb@@@\relax
		% (RE)COMPUTE:
		%
		% Determine tight 2D bounding box for the axis as such:
		\begingroup
		\pgfinterruptboundingbox
			\pgf@relevantforpicturesizetrue
			\pgfplots@clippath@install{\pgfusepath{discard}}
		\endpgfinterruptboundingbox
		\endgroup
	\fi
}%

% Point commands which expand to the bounding box which contains at
% least the (projected) visible part of the axis
\def\pgfplotspointbblowerleft{%
	\pgfplotspointbb@assertvaluesexist
	\expandafter\pgfplotspointbblowerleft@\pgfplotspoint@bb@@@
}%
\def\pgfplotspointbbupperright{%
	\pgfpointadd{\pgfplotspointbblowerleft}{\pgfplotspointbbdiagonal}%
}%
\def\pgfplotspointbbdiagonal{%
	\pgfplotspointbb@assertvaluesexist
	\expandafter\pgfplotspointbbdiagonal@\pgfplotspoint@bb@@@
}%
\let\pgfplotspoint@bb@@@=\relax
\def\pgfplotspointbblowerleft@#1#2#3#4{\global\pgf@x=#1 \global\pgf@y=#2 }%
\def\pgfplotspointbbdiagonal@#1#2#3#4{\global\pgf@x=#3 \global\pgf@y=#4 }%

% #1: a complete \pgfusepath command what to do with the clip path.
\def\pgfplots@clippath@install#1{%
	\pgfplots@error{Can't install a clippath here - the command has not yet been prepared.}%
}%

% This is the counterpart for \pgfplots@BEGIN@init@and@draw@axis
\def\pgfplots@END@init@and@draw@axis{%
	\endscope%
	%
	\ifpgfplots@axis@on@top
		\pgfplots@draw@axis
	\fi
	\pgfplots@draw@axis@post
	%
	% whats the better sequence for \ifpgfplots@axis@on@top and \ifpgfplots@clip@marker@paths !? 
	% This here looks better, I think... markers should not be obscured by descriptions.
	\ifpgfplots@clip@marker@paths
	\else
		\pgfplotslistforeach\pgfplots@stored@markerlist\as\pgfplots@loc@TMPa{%
			\scope% make sure that 'fill opacity' and 'dotted' styles remain local!
%\message{Executing marker stuff: \meaning\pgfplots@loc@TMPa]]]]]}%
%\tracingmacros=2\tracingcommands=2
			\pgfplots@loc@TMPa
			\endscope
		}%
		\global\pgfplotslistnewempty\pgfplots@stored@markerlist% clear.
	\fi
	%
	\begingroup
	\pgfkeysvalueof{/pgfplots/after end axis/.@cmd}\pgfeov%
	\endgroup
	%
}

% Writes output to \pgfmathresult
% #1: the tick list (not a macro!)
% #2: the axis
\def\pgfplots@filter@input@ticks@with@log#1#2{%
	\let\pgfplots@glob@TMPa=\pgfutil@empty
	\foreach \pgfplots@loc@TMPb in {#1} {%
		\csname pgfplotsmathlog@#2@\endcsname{\pgfplots@loc@TMPb}%
		\ifx\pgfplots@glob@TMPa\pgfutil@empty
			\xdef\pgfplots@glob@TMPa{\pgfmathresult}%
		\else
			\xdef\pgfplots@glob@TMPa{\pgfplots@glob@TMPa,\pgfmathresult}%
		\fi
	}%
	\let\pgfmathresult=\pgfplots@glob@TMPa
}

% Writes output to \pgfmathresult
% #1: the input ticks
% #2: the transformation command key as macro
\def\pgfplots@filter@input@ticks@with@highleveltrafo#1#2{%
	\let\pgfplots@glob@TMPa=\pgfutil@empty
	\foreach \pgfplots@loc@TMPb in {#1} {%
		\expandafter#2\expandafter{\pgfplots@loc@TMPb}\pgfeov%
		\ifx\pgfplots@glob@TMPa\pgfutil@empty
			\xdef\pgfplots@glob@TMPa{\pgfmathresult}%
		\else
			\xdef\pgfplots@glob@TMPa{\pgfplots@glob@TMPa,\pgfmathresult}%
		\fi
	}%
	\let\pgfmathresult=\pgfplots@glob@TMPa
}

\tikzdeclarecoordinatesystem{axis}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface\pgfplots@loc@TMPa\pgfplots@coord@end}
\def\pgfplotspointaxisxy#1#2{\pgfplots@evalute@tikz@coord@system@interface#1,#2\pgfplots@coord@end}%
\def\pgfplotspointaxisxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface#1,#2,#3\pgfplots@coord@end}%

\tikzdeclarecoordinatesystem{rel axis}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface@rel\pgfplots@loc@TMPa\pgfplots@coord@end}
\def\pgfplotspointrelaxisxy#1#2{\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2\pgfplots@coord@end}%
\def\pgfplotspointrelaxisxyz#1#2#3{\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2,#3\pgfplots@coord@end}%

\tikzdeclarecoordinatesystem{axis description}{\edef\pgfplots@loc@TMPa{#1}\expandafter\pgfplots@evalute@tikz@coord@system@interface@axis@description\pgfplots@loc@TMPa\pgfplots@coord@end}
\def\pgfplots@evalute@tikz@coord@system@interface@axis@description#1,#2\pgfplots@coord@end{\pgfplotspointdescriptionxy{#1}{#2}}

\def\pgfplotstransformcoordinatex#1{\pgfplots@evalute@tikz@coord@system@interface@for{x}{#1}}%
\def\pgfplotstransformcoordinatey#1{\pgfplots@evalute@tikz@coord@system@interface@for{y}{#1}}%
\def\pgfplotstransformcoordinatez#1{\pgfplots@evalute@tikz@coord@system@interface@for{z}{#1}}%

% Assigns \pgfmathresult := canvas coordinate (#2) for axis #1.
\long\def\pgfplots@evalute@tikz@coord@system@interface@for#1#2{%
	\pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc
	\edef\pgfmathresult{#2}%
	\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
	\else
		\expandafter\pgfplots@loc@TMPc\expandafter{\pgfmathresult}\pgfeov
	\fi
	\let\pgfplots@loc@TMPc=\pgfmathresult% FIXME: is that necessary? I doubt it... but just to make sure...
	\csname ifpgfplots@#1islinear\endcsname
		\pgfplots@if{pgfplots@apply@datatrafo@#1}{%
			\csname pgfplots@datascaletrafo@fromfixed@#1\endcsname{\pgfplots@loc@TMPc}%
		}{}%
	\else
		\pgfmathlog@{\pgfplots@loc@TMPc}%
	\fi
}

\long\def\pgfplots@evalute@tikz@coord@system@interface#1,#2\pgfplots@coord@end{%
	\global\let\pgfplots@glob@TMPc=\pgfutil@empty
	\begingroup
	\pgfplots@evalute@tikz@coord@system@interface@for{x}{#1}%
	\let\pgfplots@evaluate@tikz@coord@x=\pgfmathresult
	\edef\pgfplots@loc@TMPa{#2}%
	\expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}%
	\ifpgfutil@in@
		\def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{%
			\def\pgfplots@axiscs@y{##1}%
			\def\pgfplots@axiscs@z{##2}%
		}%
		\expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI
		\pgfplots@evalute@tikz@coord@system@interface@for{y}{\pgfplots@axiscs@y}%
		\let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult
		\pgfplots@evalute@tikz@coord@system@interface@for{z}{\pgfplots@axiscs@z}%
		\let\pgfplots@evaluate@tikz@coord@z=\pgfmathresult
	\else
		\pgfplots@evalute@tikz@coord@system@interface@for{y}{#2}%
		\let\pgfplots@evaluate@tikz@coord@y=\pgfmathresult
		\let\pgfplots@evaluate@tikz@coord@z=\pgfutil@empty
	\fi
	\xdef\pgfplots@glob@TMPa{\pgfplots@evaluate@tikz@coord@x}%
	\xdef\pgfplots@glob@TMPb{\pgfplots@evaluate@tikz@coord@y}%
	\xdef\pgfplots@glob@TMPc{\pgfplots@evaluate@tikz@coord@z}%
	\endgroup
	\ifx\pgfplots@glob@TMPc\pgfutil@empty
		\pgfplotsqpointxy{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}%
	\else
		\pgfplotsqpointxyz{\pgfplots@glob@TMPa}{\pgfplots@glob@TMPb}{\pgfplots@glob@TMPc}%
	\fi
}
\long\def\pgfplots@evalute@tikz@coord@system@interface@rel#1,#2\pgfplots@coord@end{%
	\begingroup
	\pgfkeys{/pgf/fpu=false}%
	\pgfmathparse{#1}%
	\let\pgfplots@axiscs@x=\pgfmathresult
	\edef\pgfplots@loc@TMPa{#2}%
	\expandafter\pgfutil@in@\expandafter,\expandafter{\pgfplots@loc@TMPa}%
	\ifpgfutil@in@
		\def\pgfplots@loc@TMPb##1,##2\pgfplots@EOI{%
			\pgfmathparse{##1}%
			\let\pgfplots@axiscs@y=\pgfmathresult
			\pgfmathparse{##2}%
			\let\pgfplots@axiscs@z=\pgfmathresult
		}%
		\expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\pgfplots@EOI
	\else
		\pgfmathparse{#2}%
		\let\pgfplots@axiscs@y=\pgfmathresult
		\def\pgfplots@axiscs@z{}%
	\fi
	\pgfplotspointxaxis
	\pgf@xx=\pgf@x
	\pgf@xy=\pgf@y
	%
	\pgfplotspointyaxis
	\pgf@yx=\pgf@x
	\pgf@yy=\pgf@y
	%
	\ifpgfplots@allow@reversal@of@rel@axis@cs
		\if\pgfkeysvalueof{/pgfplots/x dir/value}r%
			\pgf@xa=-\pgfplots@axiscs@x pt
			\advance\pgf@xa by1pt
			\edef\pgfplots@axiscs@x{\pgf@sys@tonumber\pgf@xa}%
		\fi
		\if\pgfkeysvalueof{/pgfplots/y dir/value}r%
			\pgf@xa=-\pgfplots@axiscs@y pt
			\advance\pgf@xa by1pt
			\edef\pgfplots@axiscs@y{\pgf@sys@tonumber\pgf@xa}%
		\fi
	\fi
	%
	\ifx\pgfplots@axiscs@z\pgfutil@empty
		\pgfpointadd
			{\pgfplotspointminminmin}%
			{\pgfplotsqpointxy{\pgfplots@axiscs@x}{\pgfplots@axiscs@y}}%
	\else
		\ifpgfplots@allow@reversal@of@rel@axis@cs
			\if\pgfkeysvalueof{/pgfplots/z dir/value}r%
				\pgf@xa=-\pgfplots@axiscs@z pt
				\advance\pgf@xa by1pt
				\edef\pgfplots@axiscs@z{\pgf@sys@tonumber\pgf@xa}%
			\fi
		\fi
		\pgfplotspointzaxis
		\pgf@zx=\pgf@x
		\pgf@zy=\pgf@y
		\pgfpointadd
			{\pgfplotspointminminmin}%
			{\pgfplotsqpointxyz{\pgfplots@axiscs@x}{\pgfplots@axiscs@y}{\pgfplots@axiscs@z}}%
	\fi
	\pgf@process{}%
	\endgroup
}

% In case of (semi-) logplots, this command will 
% - assign a filter which invokes \pgfmathlog@{} for each coordinate
% - replace any user-specified coordinate by its log.
%
% All subsequent commands will then work with logarithmic coordinates.
%
% PRECONDITION: 
% - The user input options have been set correctly, 
% - the options have been set, but are not applied
%
% POSTCONDITION: 
% - any user input has been parsed
% - any user input for log-axis has been replaced by its log if
%   necessary
% - coordinate filters are prepared
%
% See also:
%     \pgfplots@check@and@apply@datatrafo@for
\def\pgfplots@prepare@coord@filtering@for#1{%
	\expandafter\let\csname pgfplotsmathlogtologten@#1@\endcsname=\pgfmathlogtologten@
	\pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc
	\expandafter\let\csname pgfplots@highlevel@trafo@#1\endcsname=\pgfplots@loc@TMPc
	\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
		% no high-level external coord trafos.
		% Simply use identity:
		\expandafter\def\csname pgfplots@prepare@#1coord\endcsname##1{%
			\edef\pgfmathresult{##1}%
		}%
	\else
		% Apply external coordinate trafo to all input values:
		\expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{%
			\noexpand\edef\noexpand\pgfmathresult{##1}%
			\expandafter\noexpand\csname pgfplots@highlevel@trafo@#1\endcsname{##1}\noexpand\pgfeov
		}%
		%
		% The transformation is now \pgfplots@loc@TMPc
		%
		% any user-specified axis limits:
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
			\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
		\fi
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1max\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
			\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
		\fi
		%
		% any user-specified tick limits:
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
			\expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult
		\fi
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmax\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\expandafter\pgfplots@loc@TMPc\expandafter{\pgfplots@loc@TMPa}\pgfeov%
			\expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
		\fi
		%
		% any user specified axis ticks:
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\def\pgfplots@loc@TMPb{data}%
			\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
				% #1tick=data is handled elsewhere...
			\else
				\expandafter\pgfplots@filter@input@ticks@with@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}%
				\expandafter\edef\csname pgfplots@#1tick\endcsname{\pgfmathresult}%
			\fi
		\fi
		\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
		\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\else
			\expandafter\pgfplots@filter@input@ticks@with@highleveltrafo\expandafter{\pgfplots@loc@TMPa}{\pgfplots@loc@TMPc}%
			\expandafter\edef\csname pgfplots@extra@#1tick\endcsname{\pgfmathresult}%
		\fi
		%
	\fi
	%
	\pgfkeysgetvalue{/pgfplots/#1filter}\pgfplots@loc@TMPa
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
	\else
		\expandafter\let\csname pgfplots@#1filter@backwcompat\endcsname=\pgfplots@loc@TMPa
		\t@pgfplots@tokc={/pgfplots/#1filter is deprecated. Please use /pgfplots/#1 filter/.code={\def\pgfmathresult{\#1}}}%
		\pgfplots@warning{\the\t@pgfplots@tokc}%
		\pgfkeys{/pgfplots/#1 filter/.code={\csname pgfplots@#1filter@backwcompat\endcsname{##1}\to\pgfmathresult}}%
	\fi
	\csname ifpgfplots@#1islinear\endcsname
		\csname pgfplots@apply@datatrafo@#1true\endcsname
		\pgfplots@apply@datatrafotrue
		\ifpgfplots@apply@datatrafo
			% Check for any existing axis limits:
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
			\fi
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1max\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
			\fi
			% Check for any existing tick limits:
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult
			\fi
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmax\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
			\fi
		\fi
	\else
		\expandafter\let\csname pgfplotsmathlog@#1@\endcsname=\pgfmathlog@
		\expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\logi
		\expandafter\let\csname pgfplotsmathlog@#1@float\endcsname=\pgfmathlog@float
		\expandafter\let\csname pgfplots@log@scale@todisplaylog@#1\endcsname=\logten
		\expandafter\let\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname=\reciproclogten
		\expandafter\def\csname pgfplotsmathlogscale@#1\endcsname{1}%
		\expandafter\def\csname pgfplotsmathlogscale@#1@inv\endcsname{1}%
		%
		% This here could be done using a high level coord trafo as
		% well! However, I don't want to risk accidentally overwritten
		% keys, so I replicate it here.
		\pgfplots@if{pgfplots@disablelogfilter@#1}{\relax}{%
			% Prepare the log to use for axis '#1'.
			%
			\pgfkeysgetvalue{/pgfplots/log basis #1}\pgfplots@loc@TMPa%
			\edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}%
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
				% log basis x={} (initial setting:)
			\else
				% use a different basis.
				%
				% 
				\pgfmathlog@{\pgfplots@loc@TMPa}%
				\let\pgfplots@loc@TMPa=\pgfmathresult
				\pgfmathparse{1/\pgfplots@loc@TMPa}%
				\expandafter\let\csname pgfplotsmathlogscale@#1\endcsname=\pgfplots@loc@TMPa
				\expandafter\let\csname pgfplotsmathlogscale@#1@inv\endcsname=\pgfmathresult
				%
				\expandafter\edef\csname pgfplotsmathlog@#1@\endcsname##1{%
					\noexpand\pgfmathlog@{##1}%
					\noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty
					\noexpand\else
						\noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter
							{\noexpand\pgfmathresult}%
							{\pgfmathresult}%
					\noexpand\fi
				}%
				\expandafter\edef\csname pgfplotsmathlog@#1@float\endcsname##1{%
					\noexpand\pgfmathlog@float{##1}%
					\noexpand\ifx\noexpand\pgfmathresult\noexpand\pgfutil@empty
					\noexpand\else
						\noexpand\expandafter\noexpand\pgfmath@basic@multiply@\noexpand\expandafter
							{\noexpand\pgfmathresult}%
							{\pgfmathresult}%
					\noexpand\fi
				}%
				%
				% generate default ticks in the 'log basis', not base 10:
				\expandafter\def\csname pgfplots@log@scale@todisplaylog@#1\endcsname{1}%
				\expandafter\def\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname{1}%
				\pgfplotsset{/pgfplots/log basis ticks=#1}%
				%
				% 
				\ifdim\pgfkeysvalueof{/pgfplots/log basis #1}pt=10pt
				\else
					\pgfplots@identify@log@minor@tick@posfalse
					\csname pgfplots@#1minorticksfalse\endcsname
					\csname pgfplots@#1minorgridsfalse\endcsname
					\expandafter\def\csname pgfplots@#1minortickstrue\endcsname{\pgfplots@error{Sorry, minor ticks are not supported for this log basis.}}%
					\expandafter\def\csname pgfplots@#1minorgridstrue\endcsname{\pgfplots@error{Sorry, minor grid lines are not supported for this log basis.}}%
				\fi
				\pgfkeyslet{/pgfplots/log basis #1/.@cmd}\pgfplots@cant@set@in@this@context
				%
				% recompute logtologten for this axis: 
				\pgfmath@basic@multiply@{\reciproclogten}{\pgfplots@loc@TMPa}%
				\expandafter\edef\csname pgfplotsmathlogtologten@#1@\endcsname##1{%
					\noexpand\pgfmath@basic@multiply@{##1}{\pgfmathresult}%
				}%
				\begingroup
					% recompute \logi for the new basis.
					\dimen1=\logi1pt \dimen1=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen1
					\dimen2=\logi2pt \dimen2=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen2
					\dimen3=\logi3pt \dimen3=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen3
					\dimen4=\logi4pt \dimen4=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen4
					\dimen5=\logi5pt \dimen5=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen5
					\dimen6=\logi6pt \dimen6=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen6
					\dimen7=\logi7pt \dimen7=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen7
					\dimen8=\logi8pt \dimen8=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen8
					\dimen9=\logi9pt \dimen9=\csname pgfplotsmathlogscale@#1@inv\endcsname\dimen9
					\xdef\pgfplots@glob@TMPa##1{%
						\noexpand\ifcase##1
						\noexpand\or0
						\noexpand\or\pgf@sys@tonumber{\dimen1 }%
						\noexpand\or\pgf@sys@tonumber{\dimen2 }%
						\noexpand\or\pgf@sys@tonumber{\dimen3 }%
						\noexpand\or\pgf@sys@tonumber{\dimen4 }%
						\noexpand\or\pgf@sys@tonumber{\dimen5 }%
						\noexpand\or\pgf@sys@tonumber{\dimen6 }%
						\noexpand\or\pgf@sys@tonumber{\dimen7 }%
						\noexpand\or\pgf@sys@tonumber{\dimen8 }%
						\noexpand\or\pgf@sys@tonumber{\dimen9 }%
						\noexpand\fi
					}%
				\endgroup
				\expandafter\let\csname pgfplotsmathlogi@#1\endcsname=\pgfplots@glob@TMPa
				%%%
				% Ok, now, I have prepared everything for the new
				% log basis!
			\fi
			%
			% any user-specified axis limits:
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1min\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1min\endcsname=\pgfmathresult
			\fi
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1max\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1max\endcsname=\pgfmathresult
			\fi
			%
			% any user-specified tick limits:
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmin\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1tickmin\endcsname=\pgfmathresult
			\fi
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tickmax\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\csname pgfplotsmathlog@#1@\endcsname{\pgfplots@loc@TMPa}%
				\expandafter\global\expandafter\let\csname pgfplots@#1tickmax\endcsname=\pgfmathresult
			\fi
			%
			% any user specified axis ticks:
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@#1tick\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\def\pgfplots@loc@TMPb{data}%
				\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb
					% #1tick=data is handled elsewhere...
				\else
					\expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}%
					\expandafter\edef\csname pgfplots@#1tick\endcsname{\pgfmathresult}%
				\fi
			\fi
			\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@extra@#1tick\endcsname
			\ifx\pgfplots@loc@TMPa\pgfutil@empty
			\else
				\expandafter\pgfplots@filter@input@ticks@with@log\expandafter{\pgfplots@loc@TMPa}{#1}%
				\expandafter\edef\csname pgfplots@extra@#1tick\endcsname{\pgfmathresult}%
			\fi
			%
			% append logarithm to prepare coord.
			%
			\t@pgfplots@toka={%
				\ifx\pgfmathresult\pgfutil@empty
				\else
					\pgfplots@if{pgfplots@disablelogfilter@#1}{%
						\pgfmathfloatparsenumber{\pgfmathresult}%
						\expandafter\pgfmathfloat@decompose@F\pgfmathresult\relax\c@pgf@counta
						\ifnum\c@pgf@counta>2 % this clears nan, inf and -inf points.
							\let\pgfmathresult=\pgfutil@empty
							\def\pgfplots@unbounded@dir{#1}%
						\else
							\pgfmathfloattofixed{\pgfmathresult}%
						\fi
					}{%
						\csname pgfplotsmathlog@#1@\endcsname{\pgfmathresult}%
						\ifx\pgfmathresult\pgfutil@empty
							% detect unbounded coords:
							\def\pgfplots@unbounded@dir{#1}%
						\fi
					}%
				\fi
			}%
			\pgfkeysgetvalue{/pgfplots/#1 coord trafo/.@cmd}\pgfplots@loc@TMPc
			\ifx\pgfplots@loc@TMPc\pgfplots@empty@command@key
				\expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{%
					\noexpand\edef\noexpand\pgfmathresult{##1}%
					\the\t@pgfplots@toka
				}%
			\else
				% This is a bit complicated... but it works: APPEND
				% the log stuff to the existing prepare method.
				\t@pgfplots@tokb=\expandafter\expandafter\expandafter{%
					\csname pgfplots@prepare@#1coord\endcsname{##1}%
				}%
				\expandafter\edef\csname pgfplots@prepare@#1coord\endcsname##1{%
					\the\t@pgfplots@tokb
					\the\t@pgfplots@toka
				}%
			\fi
		}%
	\fi
}

\def\pgfplots@create@axis@descriptions{%
	\begingroup
		%
		\pgfplots@change@pgfpoints@to@descriptioncs
		%
		\pgfplots@create@axis@descriptions@
	\endgroup
}

\def\pgfplots@create@axis@descriptions@{%
	\ifpgfplots@hide@x
	\else
				  \ifpgfplots@units@use%
						\pgfplots@show@label{x}{\pgfplots@label@units{x}}%
				  \else%
						\pgfkeysgetvalue{/pgfplots/xlabel}{\pgfplots@label@}%
						\ifx\pgfplots@label@\pgfutil@empty
						\else
							  \pgfplots@show@label{x}{\pgfplots@label@}%
						\fi
				  \fi
	\fi
	\ifpgfplots@hide@y
	\else
				  \ifpgfplots@units@use%
						\pgfplots@show@label{y}{\pgfplots@label@units{y}}%
				  \else%
						\pgfkeysgetvalue{/pgfplots/ylabel}{\pgfplots@label@}%
						\ifx\pgfplots@label@\pgfutil@empty
						\else
							  \pgfplots@show@label{y}{\pgfplots@label@}%
						\fi
				  \fi  
	\fi
	\ifpgfplots@threedim
		\ifpgfplots@hide@z
		\else
						  \ifpgfplots@units@use%
								\pgfplots@show@label{z}{\pgfplots@label@units{z}}%
						  \else%
								\pgfkeysgetvalue{/pgfplots/zlabel}{\pgfplots@label@}%
								\ifx\pgfplots@label@\pgfutil@empty
								\else
									  \pgfplots@show@label{z}{\pgfplots@label@}%
								\fi
						  \fi
		\fi
	\fi
	%
	\pgfkeysgetvalue{/pgfplots/title}\pgfplots@loc@TMPa
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
	\else
		\expandafter\pgfplots@show@title\expandafter{\pgfplots@loc@TMPa}%
	\fi
	\pgfplots@createlegend
	%
	\pgfkeysvalueof{/pgfplots/extra description/.@cmd}\pgfeov%
	%
}

\def\pgfplots@datascaletrafo@undoshift@x#1{%
	\pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}%
}%
\def\pgfplots@datascaletrafo@redoshift@x#1{%
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}%
}%
\def\pgfplots@datascaletrafo@undoshift@y#1{%
	\pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}%
}%
\def\pgfplots@datascaletrafo@redoshift@y#1{%
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}%
}%
\def\pgfplots@datascaletrafo@undoshift@z#1{%
	\pgfmathsubtract@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}%
}%
\def\pgfplots@datascaletrafo@redoshift@z#1{%
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}%
}%

% DATA TRANSFORMATION T(x) = X - xmin
%
% Input: 
%    a number in the original data range, given in **floating** point representation
% Output: 
%    a fixed point number in transformed range
%    stored in \pgfmathresult
% @see
% \pgfplots@datascaletrafo@fromfixed@x
\def\pgfplots@datascaletrafo@x#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}%
	\pgfmathfloattofixed{\pgfmathresult}%
	\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@x}%
}
\def\pgfplots@datascaletrafo@x@noshift#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@x}%
	\pgfmathfloattofixed{\pgfmathresult}%
}

% Overloaded function.
% Input:
%     a FIXED point number instead of a floating point one.
% @see \pgfplots@datascaletrafo@x
\def\pgfplots@datascaletrafo@fromfixed@x#1{%
	\pgfmathfloatparsenumber{#1}%
	\pgfplots@datascaletrafo@x{\pgfmathresult}%
}

\def\pgfplots@datascaletrafo@y#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}%
	\pgfmathfloattofixed{\pgfmathresult}%
	\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@y}%
}
\def\pgfplots@datascaletrafo@fromfixed@y#1{%
	\pgfmathfloatparsenumber{#1}%
	\pgfplots@datascaletrafo@y{\pgfmathresult}%
}
\def\pgfplots@datascaletrafo@y@noshift#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@y}%
	\pgfmathfloattofixed{\pgfmathresult}%
}
\def\pgfplots@datascaletrafo@z#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}%
	\pgfmathfloattofixed{\pgfmathresult}%
	\expandafter\pgfmathsubtract@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@SHIFT@z}%
}
\def\pgfplots@datascaletrafo@fromfixed@z#1{%
	\pgfmathfloatparsenumber{#1}%
	\pgfplots@datascaletrafo@z{\pgfmathresult}%
}
\def\pgfplots@datascaletrafo@z@noshift#1{%
	\pgfmathfloatshift@{#1}{\pgfplots@data@scale@trafo@EXPONENT@z}%
	\pgfmathfloattofixed{\pgfmathresult}%
}

% INVERSE transformation x = T^{-1}( X )
% Input: 
%    a fixed point number in transformed domain
% Output:
%    a number in the data domain, given in floating point
%    representation
%
% If the input number is approximately X=0, we will return x=0 as
% well.
%
% This allows to handle rounding inaccuracies and should not pose any
% problems.
\def\pgfplots@inverse@datascaletrafo@x#1{%
	\begingroup
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@x}%
	\let\pgfplots@inverse@datascaletrafo@@shifted=\pgfmathresult
	\pgfmathapproxequalto@{\pgfplots@inverse@datascaletrafo@@shifted}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{\pgfplots@inverse@datascaletrafo@@shifted}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@x{-\pgfplots@data@scale@trafo@EXPONENT@x}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@x}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}
\def\pgfplots@inverse@datascaletrafo@x@noshift#1{%
	\begingroup
	\pgfmathapproxequalto@{#1}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{#1}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@x{-\pgfplots@data@scale@trafo@EXPONENT@x}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@x}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}

\def\pgfplots@inverse@datascaletrafo@y#1{%
	\begingroup
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@y}%
	\let\pgfplots@inverse@datascaletrafo@@shifted=\pgfmathresult
	\pgfmathapproxequalto@{\pgfplots@inverse@datascaletrafo@@shifted}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{\pgfplots@inverse@datascaletrafo@@shifted}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@y{-\pgfplots@data@scale@trafo@EXPONENT@y}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@y}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}
% Overloaded function. This one does only apply the scaling, no shift.
\def\pgfplots@inverse@datascaletrafo@y@noshift#1{%
	\begingroup
	\pgfmathapproxequalto@{#1}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{#1}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@y{-\pgfplots@data@scale@trafo@EXPONENT@y}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@y}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}

\def\pgfplots@inverse@datascaletrafo@z#1{%
	\begingroup
	\pgfmathadd@{#1}{\pgfplots@data@scale@trafo@SHIFT@z}%
	\let\pgfplots@inverse@datascaletrafo@@shifted=\pgfmathresult
	\pgfmathapproxequalto@{\pgfplots@inverse@datascaletrafo@@shifted}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{\pgfplots@inverse@datascaletrafo@@shifted}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@z{-\pgfplots@data@scale@trafo@EXPONENT@z}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@z}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}
% Overloaded function. This one does only apply the scaling, no shift.
\def\pgfplots@inverse@datascaletrafo@z@noshift#1{%
	\begingroup
	\pgfmathapproxequalto@{#1}{0.0}%
	\ifpgfmathcomparison
		\pgfmathfloatcreate{0}{0.0}{0}%
	\else
		\pgfmathfloatparsenumber{#1}%
		\edef\pgfplots@data@scale@trafo@EXPONENT@z{-\pgfplots@data@scale@trafo@EXPONENT@z}%
		\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\pgfplots@data@scale@trafo@EXPONENT@z}%
	\fi
	\pgfmath@smuggleone\pgfmathresult
	\endgroup
}

% Overloaded function.
%
% In contrast to \pgfplots@inverse@datascaletrafo@x, this method
% returns a number in FIXED point representation.
% @see \pgfplots@inverse@datascaletrafo@x
\def\pgfplots@inverse@datascaletrafo@tofixed@x#1{%
	\pgfplots@inverse@datascaletrafo@x{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}
\def\pgfplots@inverse@datascaletrafo@tofixed@y#1{%
	\pgfplots@inverse@datascaletrafo@y{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}
\def\pgfplots@inverse@datascaletrafo@tofixed@z#1{%
	\pgfplots@inverse@datascaletrafo@z{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}

% Overloaded function.
%
% This one does only apply the scale, no shift.
\def\pgfplots@inverse@datascaletrafo@tofixed@x@noshift#1{%
	\pgfplots@inverse@datascaletrafo@x@noshift{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}
\def\pgfplots@inverse@datascaletrafo@tofixed@y@noshift#1{%
	\pgfplots@inverse@datascaletrafo@y@noshift{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}
\def\pgfplots@inverse@datascaletrafo@tofixed@z@noshift#1{%
	\pgfplots@inverse@datascaletrafo@z@noshift{#1}%
	\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}%
}

% Invokes '#1' foreach key which should be saved by a color bar.
%
% The current key name is available as '##1', the macro under which
% the key is / should be saved as '##2'.
\def\pgfplots@colorbar@foreach@saved@key#1{%
	\def\pgfplots@colorbar@foreach@saved@key@body##1##2{#1}%
	\pgfplotsutilforeachcommasep{%
		{/pgfplots/colorbar/draw/.@cmd}\pgfplots@savedstyle@colorbar@draw,%
		{/pgfplots/every colorbar/.@cmd}\pgfplots@savedstyle@colorbar,%
		{/pgfplots/colorbar shift/.@cmd}\pgfplots@savedstyle@colorbarshift,%
		{/pgfplots/colorbar horizontal/lowlevel/.@cmd}\pgfplots@savedstyle@colorbar@horizontal,%
		{/pgfplots/colorbar vertical/lowlevel/.@cmd}\pgfplots@savedstyle@colorbar@vertical,%
		{/pgfplots/every tick/.@cmd}\pgfplots@savedstyle@tick,%
		{/pgfplots/every minor tick/.@cmd}\pgfplots@savedstyle@minortick,%
		{/pgfplots/every major tick/.@cmd}\pgfplots@savedstyle@majortick,%
		{/pgfplots/every axis grid/.@cmd}\pgfplots@savedstyle@grid,%
		{/pgfplots/every minor grid/.@cmd}\pgfplots@savedstyle@minorgrid,%
		{/pgfplots/every major grid/.@cmd}\pgfplots@savedstyle@majorgrid,%
		{/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel,%
		{/pgfplots/every tick label/.@cmd}\pgfplots@savedstyle@ticklabel%
	}%
		\as\pgfplots@colorbar@foreach@saved@key@@
	{%
		\expandafter\pgfplots@colorbar@foreach@saved@key@body\pgfplots@colorbar@foreach@saved@key@@
	}%
}%
\def\pgfplots@colorbar@restore@saved@keys{%
	\pgfplots@colorbar@foreach@saved@key{%
		\pgfkeyslet{##1}##2%
	}%
}%

% Defines '#1' to be a macro which, upon execution, draws the color
% bar for the current axis. It also handles any required style
% inheritance and option preparation issues.
%
% The important thing is: the macro is expected to be invoked after
% the current TeX group (scope). Thus, the complete state is
% represented inside of '#1' (and maybe some global variables).
\def\pgfplots@colorbar@move@outside@scope@with@globalmacro#1{%
	\pgfplotspointbbdiagonal
	\edef\pgfplots@loc@TMPa{\the\pgf@x}%
	\edef\pgfplots@loc@TMPb{\the\pgf@y}%
	\pgfkeyslet{/pgfplots/parent axis width}{\pgfplots@loc@TMPa}%
	\pgfkeyslet{/pgfplots/parent axis height}{\pgfplots@loc@TMPb}%
	%
	\pgfkeysgetvalue{/pgfplots/colorbar to name}\pgfplots@colorbar@toname
	%
	\pgfnodealias{parent axis}{current axis}%
	%
	% FIXME : 
	% I would really prefer to find a different way to move these
	% variables out of the current scope. But expansion leads to
	% mistakes with '#' characters ... :-(
	\pgfplots@colorbar@foreach@saved@key{%
		\pgfkeysgetvalue{##1}\pgfplots@loc@TMPa
		\global\let##2=\pgfplots@loc@TMPa
	}%
	%
	\toks1={}%
	\ifx\pgfplots@colorbar@toname\pgfutil@empty
	\else
		\toks1={%
			\pgfkeysgetvalue{/pgfplots/at/.@cmd}\pgfplots@at@orig
			\pgfkeyslet{/pgfplots/at/orig/.@cmd}\pgfplots@at@orig
			%
			\pgfkeysgetvalue{/pgfplots/colorbar to name/at/.@cmd}\pgfplots@colorbar@toname@at
			\pgfkeyslet{/pgfplots/at/.@cmd}\pgfplots@colorbar@toname@at
		}%
		\pgfplots@colorbar@foreach@saved@key{%
			\pgfplots@command@with@args@to@string##2\pgfplots@loc@TMPa
			\pgfplots@auxwrite{%
				\noexpand\expandafter
				\noexpand\long
				\noexpand\expandafter
				\noexpand\gdef
				\noexpand\csname pgfplots@colorbar@\pgfplots@colorbar@toname @\noexpand\string\noexpand##2\noexpand\endcsname%
					\pgfplots@loc@TMPa
			}%
			\edef\pgfplots@loc@TMPa{%
				\the\toks1
				\noexpand\expandafter
				\noexpand\let
				\noexpand\expandafter
				\noexpand##2%
					\noexpand\csname pgfplots@colorbar@\pgfplots@colorbar@toname @\noexpand\string\noexpand##2\noexpand\endcsname%
			}%
			\toks1=\expandafter{\pgfplots@loc@TMPa}%
		}%
	\fi
	% %
	% we have to do a lot of work to move *some* of the current
	% settings out of the current TeX group:
	\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa
	\expandafter\pgfplotscolormapserializetomacro\expandafter{\pgfplots@loc@TMPa}{\pgfplots@serializedcolormap}%
	\toks0=\expandafter{\pgfplots@serializedcolormap}%
	%
	\pgfkeysgetvalue{/pgfplots/colorbar addplot}\pgfplots@loc@TMPa
	\toks2=\expandafter{\pgfplots@loc@TMPa}%
	%
	\ifx\pgfplots@colorbar@src@metamin\pgfutil@empty
		\global\let\pgfplots@colorbar@src@metamin=\pgfplots@axiswide@metamin
		\global\let\pgfplots@colorbar@src@metamax=\pgfplots@axiswide@metamax
	\fi
	%
	\ifx\pgfplots@colorbar@src@metamax\pgfplots@invalidrange@metamax
		\pgfplots@warning{Sorry, the colorbar is uninitialised - your axis has no color data. Consider using 'point meta=f(x)' or something like that. I am using a color range of [0,1] for the colorbar.}%
		\pgfmathfloatparsenumber{0}%
		\global\let\pgfplots@colorbar@src@metamin=\pgfmathresult
		\pgfmathfloatparsenumber{1}%
		\global\let\pgfplots@colorbar@src@metamax=\pgfmathresult
	\fi
	%
	% normalize format:
	\pgfmathfloattosci\pgfplots@colorbar@src@metamin
	\global\let\pgfplots@colorbar@src@metamin=\pgfmathresult
	\pgfmathfloattosci\pgfplots@colorbar@src@metamax
	\global\let\pgfplots@colorbar@src@metamax=\pgfmathresult
	%
	\pgfplots@assemble@ref@picture
		{\pgfplots@colorbar@draw}
		{\tikz[/pgfplots/every colorbar to name picture/.try]{\pgfplots@colorbar@draw}}%
	\toks3=\expandafter{\pgfplotsretval}%
	%
	\xdef#1{%
		\noexpand\begingroup
		\noexpand\def\noexpand\pgfplots@colorbar@draw{%
			\the\toks0 % restore colormap definition
			\noexpand\def\noexpand\pgfplots@colorbar@toname{\pgfplots@colorbar@toname}%
			\the\toks1 % definitions for 'colorbar to name'
			%
			%  restore relevant styles and variables:
			\noexpand\pgfplots@colorbar@restore@saved@keys
			\noexpand\pgfkeyssetvalue{/pgfplots/point meta min}{\pgfplots@colorbar@src@metamin}%
			\noexpand\pgfkeyssetvalue{/pgfplots/point meta max}{\pgfplots@colorbar@src@metamax}%
			\noexpand\pgfkeyssetvalue{/pgfplots/colormap name}{\pgfkeysvalueof{/pgfplots/colormap name}}%
			\noexpand\pgfkeyssetvalue{/pgfplots/parent axis width}{\pgfkeysvalueof{/pgfplots/parent axis width}}%
			\noexpand\pgfkeyssetvalue{/pgfplots/parent axis height}{\pgfkeysvalueof{/pgfplots/parent axis height}}%
			\noexpand\pgfkeyssetvalue{/pgfplots/colorbar/width}{\pgfkeysvalueof{/pgfplots/colorbar/width}}%
			\noexpand\pgfkeyssetvalue{/pgfplots/colorbar addplot}{\the\toks2 }%
			\noexpand\pgfkeyssetvalue{/pgfplots/colorbar pos*}{\pgfkeysvalueof{/pgfplots/colorbar pos*}}%
			\noexpand\pgfplots@colorbar@define@hook%
			\noexpand\pgfkeysvalueof{/pgfplots/colorbar/draw/.@cmd}\noexpand\pgfeov
			\ifx\pgfplots@colorbar@toname\pgfutil@empty
				\noexpand\pgfnodealias{current colorbar axis}{current axis}%
				\noexpand\pgfnodealias{current axis}{parent axis}%
			\fi
		}%
		\the\toks3
		\noexpand\endgroup
	}%
	\ifx\pgfplots@colorbar@toname\pgfutil@empty
	\else
		% finalize the 'colorbar to name' feature
		\toks0=\expandafter{#1}%
		\pgfplots@auxwrite{%
			\noexpand\expandafter
			\noexpand\gdef\noexpand\csname pgfplots@colorbar@to@name@\pgfplots@colorbar@toname\endcsname{\the\toks0}}%
		\xdef#1{}% NOP.
		% 
		% make sure \ref{<colorbarname>} works:
		\pgfplots@label{\pgfplots@colorbar@toname}{pgfplots@colorbar@to@name@}%
	\fi
}%
\pgfkeysdef{/pgfplots/colorbar to name/at}{%
	% automatically search-and-replace 'parent axis' which
	% is not defined for a detached colorbar:
	\pgfutil@in@{parent axis}{#1}%
	\ifpgfutil@in@
		\pgfplots@invoke@pgfkeyscode{/pgfplots/at/orig/.@cmd}{(0pt,0pt)}%
	\else
		\pgfplots@invoke@pgfkeyscode{/pgfplots/at/orig/.@cmd}{#1}%
	\fi
}%
\let\pgfplots@colorbar@position@hook\relax
\def\pgfplots@colorbar@define@hook{%
	\ifx\pgfplots@colorbar@toname\pgfutil@empty
		\def\pgfplots@colorbar@position@hook{%
			% I patch \pgfplots@at...
			\let\pgfplots@at@orig=\pgfplots@at
			%
			% ... and I patch \pgfplotspointdescriptionxy (but only INSIDE
			% of \pgfplots@at) ...
			\let\pgfplotspointdescriptionxy@orig=\pgfplotspointdescriptionxy
			\let\pgfplotsqpointdescriptionxy@orig=\pgfplotsqpointdescriptionxy
			\def\pgfplots@colorbar@position@prepare@CS{%
				% ... which needs to set up ONLY \pgfplotspoint@bb@@@,
				% nothing more.
				\pgfpointanchor{parent axis}{south west}%
				\edef\pgfplotspoint@bb@@@{%
					{\the\pgf@x}%
					{\the\pgf@y}%
					{\pgfkeysvalueof{/pgfplots/parent axis width}}%
					{\pgfkeysvalueof{/pgfplots/parent axis height}}%
				}%
			}%
			%
			% Install replacements:
			\def\pgfplots@at{%
				\begingroup
				\def\pgfplotspointdescriptionxy########1########2{%
					\pgfplots@colorbar@position@prepare@CS
					\pgfplotspointdescriptionxy@orig{########1}{########2}%
				}%
				\def\pgfplotsqpointdescriptionxy########1########2{%
					\pgfplots@colorbar@position@prepare@CS
					\pgfplotsqpointdescriptionxy@orig{########1}{########2}%
				}%
				\pgfplots@deprecated@anchorsfalse
				\pgfplots@change@pgfpoints@to@descriptioncs
				\pgf@process{\pgfplots@at@orig}%
				\endgroup
			}%
		}%
	\else
		% nothing to do for colorbar to name:
		\let\pgfplots@colorbar@position@hook=\relax
	\fi
}%

% Parses all options in #1 which are known in the currently active families.
%
% The result will be stored back into the TikZ-style named #1 without 
% further processing.
%
% Example:
% \tikzstyle{every axis}=[xmin=0,xmax=1,line width=1pt
% \pgfplots@set@keys@from@tikz@style\tmpmacro{every axis}{/pgfplots}
% 
% - sets axis options 'xmin' and 'xmax'
% - calls \tikzstyle{every axis}={line width=1pt}
% 
% I assume that this method is called within local TeX groups so
% nothing will be destroyed outside.
%
% #1:  A style name.
\def\pgfplots@set@keys@from@tikz@style#1{%
	\let\pgfplots@rmopts=\pgfutil@empty
	\pgfqkeysfiltered{/pgfplots}{/pgfplots/#1}%
	\pgfplots@set@keymacro@to@style\pgfplots@rmopts{#1}%
}

% The same as \pgfplots@set@keys@from@tikz@style  but this one appends
% unmatched options to style #2.
%
% #1:  A style name.
% #2:  A style name which will be filled with unprocessed options.
\def\pgfplots@set@keys@from@tikz@style@append@to#1#2{%
	\let\pgfplots@rmopts=\pgfutil@empty
	\pgfqkeysfiltered{/pgfplots}{/pgfplots/#1}%
	\pgfplots@append@keymacro@to@style\pgfplots@rmopts{#2}%
}

% #1:  A sequence of options.
% #2:  A style name which will be filled with unprocessed options.
\def\pgfplots@set@keys@and@append@remaining@to@style#1#2{%
	\let\pgfplots@rmopts=\pgfutil@empty
	\pgfqkeysfiltered{/pgfplots}{#1}%
	\pgfplots@append@keymacro@to@style\pgfplots@rmopts{#2}%
}%

% #1: input macro
\def\pgfplots@setkeys@from@macro#1{%
	\let\pgfplots@rmopts=\pgfutil@empty
	\def\pgfplots@loc@TMPa{\pgfqkeysfiltered{/pgfplots}}%
	\expandafter\pgfplots@loc@TMPa\expandafter{#1}%
}

% #1: macro
% #2: style name
\long\def\pgfplots@append@keymacro@to@style#1#2{%
	\ifx#1\pgfutil@empty
	\else
		\t@pgfplots@toka={#2/.append style=}%
		\t@pgfplots@tokb=\expandafter{#1}%
		\edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}%
		\expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}%
	\fi
%\pgfplots@message{tikzstyle{#2}+=[#1]}%
}

% #1: macro
% #2: style name
\long\def\pgfplots@set@keymacro@to@style#1#2{%
	\ifx#1\pgfutil@empty
		\pgfplotsset{#2/.code={{}}}%
	\else
		\t@pgfplots@toka={#2/.style=}%
		\t@pgfplots@tokb=\expandafter{#1}%
		\edef\pgfplots@setkeys@TMP{\the\t@pgfplots@toka{\the\t@pgfplots@tokb}}%
		\expandafter\pgfplotsset\expandafter{\pgfplots@setkeys@TMP}%
	\fi
%\pgfplots@message{tikzstyle{#2}=[#1]}%
}

% backwards compatibility:
\let\prettyprintnumber=\pgfmathprintnumber%


\def\pgfplots@set@options@sanitizemode{%
	\pgfkeyslet{/pgfplots/xmode/.@cmd}\pgfplots@cant@set@in@this@context@
	\pgfkeyslet{/pgfplots/ymode/.@cmd}\pgfplots@cant@set@in@this@context@
	\pgfkeyslet{/pgfplots/zmode/.@cmd}\pgfplots@cant@set@in@this@context@
}
\def\pgfplots@set@options@sanitize{%
	\pgfkeyslet{/pgfplots/xmin/.@cmd}\pgfplots@cant@set@in@this@context
	\pgfkeyslet{/pgfplots/ymin/.@cmd}\pgfplots@cant@set@in@this@context
	\pgfkeyslet{/pgfplots/zmin/.@cmd}\pgfplots@cant@set@in@this@context
	\pgfkeyslet{/pgfplots/xmax/.@cmd}\pgfplots@cant@set@in@this@context
	\pgfkeyslet{/pgfplots/ymax/.@cmd}\pgfplots@cant@set@in@this@context
	\pgfkeyslet{/pgfplots/zmax/.@cmd}\pgfplots@cant@set@in@this@context
}%

% This here is the main key filter for pgfplots.
%
% It sets keys if
% ( they have an active key family)
% OR
% ( they have /pgfplots/ key prefix )
% OR
% ( they are a command key which contains \tikz@plot@handler ).
%
% In all other cases, the key filter will postpone the key.
%
% Note that \tikz@plot@handler should be defined before the survey
% phase starts.
\pgfkeysdef{/pgfplots/@@key filter}{%
	\if\pgfkeyscasenumber0%
		\pgfkeysfiltercontinuefalse
	\else
		\if\pgfkeyscasenumber3%
			\pgfkeysgetfamily\pgfkeyscurrentpath\pgfkeyspred@TMP
		\else
			\pgfkeysgetfamily\pgfkeyscurrentkey\pgfkeyspred@TMP
		\fi
		\ifpgfkeyssuccess
			% it has a family. Check it!
			\pgfkeysisfamilyactive{\pgfkeyspred@TMP}%
		\else% Ok, it does not belong to any family.
			% Check if it has /pgfplots/ prefix:
			\expandafter\pgfplots@key@filter@isdescendantof\pgfkeyscurrentkey/pgfplots/\pgf@@eov
		\fi
	\fi
}
\def\pgfplots@key@filter@isdescendantof#1/pgfplots/#2\pgf@@eov{%
	\def\pgfkeyspred@TMP{#1}%
	\ifx\pgfkeyspred@TMP\pgfkeys@empty
		% Ah -- it *has* /pgfplots/ prefix. Use it!
		\pgfkeysfiltercontinuetrue
	\else
		% Hm. Probably a /tikz/ key, but who knows.
		\if1\pgfkeyscasenumber
			% It is a command key.
			% Check if the *body* of the command key contains
			% \tikz@plot@handler.
			\pgfkeysgetvalue{\pgfkeyscurrentkey/.@cmd}\pgfkeyspred@TMP%
			\expandafter\pgfplots@key@filter@isplothandler\pgfkeyspred@TMP 123456789\pgfeov\tikz@plot@handler\pgfplots@EOI
		\else
			% Ok, it's no command key. Skip it directly.
			\pgfkeysfiltercontinuefalse
		\fi
	\fi
}%
\def\pgfplots@key@filter@isplothandler#1\tikz@plot@handler#2\pgfplots@EOI{%
	\def\pgfkeyspred@TMP{#2}%
	\ifx\pgfkeyspred@TMP\pgfkeys@empty
		% I didn't find '\tikz@plot@handler' in the key's body. Ok.
		% key won't be processed.
		\pgfkeysfiltercontinuefalse
	\else
		% Aaah -- it is something like /tikz/ybar! process it.
		\pgfkeysfiltercontinuetrue
	\fi
}%

\def\pgfplots@set@options#1{%
	\pgfplots@bb@isactivetrue
	\pgfplots@curplot@threedimfalse
	\global\pgfplots@threedimfalse
	\pgfutil@ifundefined{tikz@lastx}{%
		% no warning. Its not that important anyway, I think.
		\def\pgfplots@at{\pgfpointorigin}%
	}{%
		\def\pgfplots@at{\pgfqpoint{\the\tikz@lastx}{\the\tikz@lasty}}%
	}%
	%
	% Temporarily assign families to 'name' and 'alias' options.
	% This allows to get the names - they should not be appended to
	% 'every axis'!
	\pgfkeyssetfamily{/tikz/name}{/pgfplots/naming commands}%
	\pgfkeyssetfamily{/tikz/alias}{/pgfplots/naming commands}%
	\pgfkeyssetfamily{/tikz/overlay}{/pgfplots/shared with tikz}%
	\pgfkeyssetfamily{/tikz/variable}{/pgfplots}%
	\pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@rmopts}%
	%
	\let\tikz@alias=\pgfutil@empty
	\let\tikz@fig@name=\pgfutil@empty
	%
	% Step 1: acquire ONLY 'xmode' and 'ymode' (necessary to decide
	% which axis style shall be loaded):
		\let\pgfplots@rmopts=\pgfutil@empty
		\pgfkeysinstallkeyfilter{/pgf/key filters/active families and known}{}%
		%
		\pgfqkeysactivatesinglefamilyandfilteroptions{/pgfplots/scale}%
			{/pgfplots}
			{#1}%
	\let\pgfplots@remaining@input=\pgfplots@rmopts
	%
	% Step 2: parse any pgfplots options out of styles.
	\pgfkeysactivatefamily{/pgfplots/style commands}%
	%\pgfkeysinstallkeyfilter{/pgf/key filters/active families or descendants of}{/pgfplots}
	\pgfkeysinstallkeyfilter{/pgfplots/@@key filter}{}%
	%
	\pgfkeysactivatefamilies
		{/pgfplots,/pgfplots/naming commands,/pgfplots/tick,/pgfplots/legend,/pgfplots/scale}%/pgfplots/descriptions,}
		{\pgfplots@deactivefamiliescmd}%
		\pgfplots@set@keys@from@tikz@style{every axis}%
		\pgfkeysdeactivatefamily{/pgfplots/scale}%
		%
		\ifpgfplots@xislinear
			\ifpgfplots@yislinear
				\pgfplots@set@keys@from@tikz@style@append@to{every linear axis}{every axis}%
			\else
				\pgfplots@set@keys@from@tikz@style@append@to{every semilogy axis}{every axis}%
			\fi
		\else
			\ifpgfplots@yislinear
				\pgfplots@set@keys@from@tikz@style@append@to{every semilogx axis}{every axis}%
			\else
				\pgfplots@set@keys@from@tikz@style@append@to{every loglog axis}{every axis}%
			\fi
		\fi
	\pgfplots@deactivefamiliescmd
	\pgfplots@set@options@sanitizemode
	%
	% Acquire style commands and nameing commands from direct input
	% options '#1' BEFORE the 'every' styles are processed:
	\pgfkeysactivatefamily{/pgfplots/naming commands}%
	\pgfkeysactivatefamily{/pgfplots/shared with tikz}%
		\pgfplots@setkeys@from@macro\pgfplots@remaining@input%
		\let\pgfplots@remaining@input=\pgfplots@rmopts
	\pgfkeysdeactivatefamily{/pgfplots/naming commands}%
	\pgfkeysdeactivatefamily{/pgfplots/shared with tikz}%
	%
	% Now, any 'name' and 'alias' options have been processed. 
	%
	% Remember their current meaning and reset the tikz options!
	\let\pgfplots@fig@name=\tikz@fig@name
	\let\pgfplots@fig@alias=\tikz@alias
	\let\tikz@alias=\pgfutil@empty
	\let\tikz@fig@name=\pgfutil@empty
	%
	% And protocol all named sub-nodes! Their positions need to be
	% updated later.
	\global\let\pgfplots@named@child@node@list=\pgfutil@empty
	\pgfutil@ifundefined{pgfplots@old@name@impl}{%
		\pgfkeysgetvalue{/tikz/name/.@cmd}\pgfplots@old@name@impl
		\pgfkeysgetvalue{/tikz/alias/.@cmd}\pgfplots@old@alias@impl
	}{}%
	\pgfkeysdef{/tikz/name}{%
		\xdef\pgfplots@named@child@node@list{\pgfplots@named@child@node@list,{##1}}%
		\pgfplots@old@name@impl##1\pgfeov
	}%
	\pgfkeysdef{/tikz/alias}{%
		\xdef\pgfplots@named@child@node@list{\pgfplots@named@child@node@list,{##1}}%
		\pgfplots@old@alias@impl##1\pgfeov
	}%
	%
	% Now, continue to process the 'every' styles. Please note that
	% the 'legend style={}' like options have already been processed;
	% their values are already inside of the associated 'every'
	% styles.
	%
	% What I am doing here is: set every pgfplots-option directly, and
	% discard it from the every-style. Any non-pgfplots-option will
	% be set in its context.
	%
	\pgfkeysactivatefamily{/pgfplots/legend}%
		% this special treatmeant allows the (otherwise unsupported) construction
		% 'legend style={legend pos=outer north east}':
		\pgfkeysdef{/pgfplots/every axis legend/.append style}{\pgfkeysalso{##1}}%
		%
		\pgfplots@set@keys@from@tikz@style{every axis legend}%
		%
		% restore:
		\pgfkeysdef{/pgfplots/every axis legend/.append style}{%
			\pgfkeysalso{/pgfplots/every axis legend/.add code={}{\pgfkeysalso{##1}}}%
		}%
	\pgfkeysdeactivatefamily{/pgfplots/legend}%
	%
	% FIXME : VERIFY!
	% If I am not mistaken, these statements are only useful to allow
	% 'xlabel style={xlabel=$x$}'  --- which is not intuitive anyway.
	%\pgfkeysactivatefamily{/pgfplots/descriptions}%
	%	\pgfplots@set@keys@from@tikz@style{every axis label}%
	%	\pgfplots@set@keys@from@tikz@style{every axis x label}%
	%	\pgfplots@set@keys@from@tikz@style{every axis y label}%
	%	\pgfplots@set@keys@from@tikz@style{every axis title}%
	%\pgfkeysdeactivatefamily{/pgfplots/descriptions}%
	%
	\pgfkeysactivatefamily{/pgfplots/tick}%
		\pgfplots@set@keys@from@tikz@style{every tick}%
		\pgfplots@set@keys@from@tikz@style{every minor tick}%
		\pgfplots@set@keys@from@tikz@style{every major tick}%
		\pgfplots@set@keys@from@tikz@style{every axis grid}%
		\pgfplots@set@keys@from@tikz@style{every minor grid}%
		\pgfplots@set@keys@from@tikz@style{every major grid}%
	\pgfkeysdeactivatefamily{/pgfplots/tick}%
	%
	%--------------------------------------------------
	% \pgfkeysactivatefamily{/pgfplots}%
	% 	\pgfplots@set@keys@from@tikz@style{every axis plot}%
	% \pgfkeysdeactivatefamily{/pgfplots}%
	%-------------------------------------------------- 
	%
	% Attention: do NOT set the description styles here! Setting them
	% must be postponed until |every 3d description| has been set (to
	% ensure that \axis[<options>] take higher precedence).
	%\pgfkeysactivatefamily{/pgfplots/descriptions}%
	\pgfkeysactivatefamily{/pgfplots/tick}%
		\pgfplots@set@keys@from@tikz@style{every x tick label}%
		\pgfplots@set@keys@from@tikz@style{every y tick label}%
		\pgfplots@set@keys@from@tikz@style{every tick label}%
	\pgfkeysdeactivatefamily{/pgfplots/tick}%
	%\pgfkeysdeactivatefamily{/pgfplots/descriptions}%
	%
	% Step 3: Set all remaining options of '#1'. They should have
	% highest precedence.
	\pgfkeysactivatefamilies
		{/pgfplots,/pgfplots/tick,/pgfplots/legend}%,/pgfplots/descriptions}%
		{\pgfplots@deactivefamiliescmd}%
		\expandafter
			\pgfplots@set@keys@and@append@remaining@to@style
		\expandafter
			{\pgfplots@remaining@input}%
			{every axis}%
	\pgfplots@deactivefamiliescmd
%\pgfkeysgetvalue{/pgfplots/every axis/.@cmd}\pgfplots@loc@TMPa
%\message{every axis is now '\meaning\pgfplots@loc@TMPa'}%
	%
	\pgfkeysdeactivatefamily{/pgfplots/style commands}%
	\global\pgfkeysgetvalue{/pgfplots/xmin}{\pgfplots@xmin}%
	\global\pgfkeysgetvalue{/pgfplots/xmax}{\pgfplots@xmax}%
	\global\pgfkeysgetvalue{/pgfplots/ymin}{\pgfplots@ymin}%
	\global\pgfkeysgetvalue{/pgfplots/ymax}{\pgfplots@ymax}%
	\global\pgfkeysgetvalue{/pgfplots/zmin}{\pgfplots@zmin}%
	\global\pgfkeysgetvalue{/pgfplots/zmax}{\pgfplots@zmax}%
	\pgfkeysgetvalue{/pgfplots/xtickmin}{\pgfplots@xtickmin}%
	\pgfkeysgetvalue{/pgfplots/xtickmax}{\pgfplots@xtickmax}%
	\pgfkeysgetvalue{/pgfplots/ytickmin}{\pgfplots@ytickmin}%
	\pgfkeysgetvalue{/pgfplots/ytickmax}{\pgfplots@ytickmax}%
	\pgfkeysgetvalue{/pgfplots/ztickmin}{\pgfplots@ztickmin}%
	\pgfkeysgetvalue{/pgfplots/ztickmax}{\pgfplots@ztickmax}%
	%
	\def\pgfplots@loc@TMPa{data}%
	\pgfplots@collect@firstplot@astickfalse
	\ifx\pgfplots@xtick\pgfplots@loc@TMPa
		\pgfplots@collect@firstplot@asticktrue
	\fi
	\ifx\pgfplots@ytick\pgfplots@loc@TMPa
		\pgfplots@collect@firstplot@asticktrue
	\fi
	\ifx\pgfplots@ztick\pgfplots@loc@TMPa
		\pgfplots@collect@firstplot@asticktrue
	\fi
	\ifpgfplots@collect@firstplot@astick
		\global\let\pgfplots@firstplot@coords@x=\pgfutil@empty
		\global\let\pgfplots@firstplot@coords@y=\pgfutil@empty
		\global\let\pgfplots@firstplot@coords@z=\pgfutil@empty
	\fi
	\pgfkeysalso{/pgfplots/.search also=/tikz}%
	%
	\pgfplots@set@options@sanitize
}

\def\pgfplots@install@abbrev@commands{
	\let\pgfplots@orig@path=\path
	\let\pgfplots@orig@plot=\plot
	%
	\let\axispath=\pgfplots@path
	\let\pgfplotsinterruptdatabb=\pgfplots@interruptdatabb
	\let\endpgfplotsinterruptdatabb=\endpgfplots@interruptdatabb
	%
	\let\addplot=\pgfplots@addplot
	\let\plot=\addplot
	%
	%
	\def\logten{2.3025851}%
	\def\reciproclogten{0.434294}%
	%
	\def\logi##1{%
		\ifcase##1
		\or0
		\or0.693147
		\or1.098612
		\or1.386294
		\or1.60943791
		\or1.7917594
		\or1.94591014
		\or2.07944154
		\or2.197224
		\fi
	}%
	\def\axisdefaultticklabel{$\pgfmathprintnumber{\tick}$}%
	\def\axisdefaultticklabellog{%
		\pgfkeysgetvalue{/pgfplots/log number format code/.@cmd}\pgfplots@log@label@style
		\expandafter\pgfplots@log@label@style\tick\pgfeov
	}%
	%
	\let\legend=\pgfplots@command@legend
	\let\addlegendimage=\pgfplots@addlegendimage
	\let\addlegendentry=\pgfplots@addlegendentry
	\let\addlegendentryexpanded=\pgfplots@addlegendentryexpanded
}

\def\pgfplots@environment{%
	\pgfutil@ifnextchar[{%
		\pgfplots@environment@opt
	}{%
		\pgfplots@environment@opt[]%
	}%
}%

% temporary (local) variables inside of axis
\newif\ifpgfplots@autocompute@all@limits
\newif\ifpgfplots@autocompute@xmin
\newif\ifpgfplots@autocompute@xmax
\newif\ifpgfplots@autocompute@ymin
\newif\ifpgfplots@autocompute@ymax
\newif\ifpgfplots@autocompute@zmin
\newif\ifpgfplots@autocompute@zmax
\newif\ifpgfplots@apply@datatrafo@x
\newif\ifpgfplots@apply@datatrafo@y
\newif\ifpgfplots@apply@datatrafo@z
\newif\ifpgfplots@apply@datatrafo
\newif\ifpgfplots@datascaletrafo@initialised

% Extracts single components of an entry of
% \pgfplots@stored@plotlist
%
% They are defined as
% \pgfplots@stored@current@precmd
% \pgfplots@stored@current@cmd
% \pgfplots@stored@current@data
% \pgfplots@stored@current@postcmd
\def\pgfplots@stored@plotlist@EXTRACTENTRY#1#2#3#4{%
	\def\pgfplots@stored@current@precmd{#1}%
	\def\pgfplots@stored@current@cmd{#2}%
	\def\pgfplots@stored@current@data{#3}%
	\def\pgfplots@stored@current@postcmd{#4}%
}

\def\pgfplots@init@cleared@structures{%
	\global\pgfplotslistnewempty\pgfplots@plotspeclist
	\global\pgfplotslistnewempty\pgfplots@legend
	\global\pgfplotslistnewempty\pgfplots@stored@plotlist
	\global\pgfplots@numplots=0
	\let\pgfplots@already@computed@legend@node=\pgfutil@empty
}

% Takes a plot style and exports it to a self-contained drawing
% command which can be used outside of the current context.
%
% This macro is used inside for \label{} / \ref{}; it tries to be
% reasonable smart about restoring relevant flags stored in a pgfplots
% axis. If it forgets something... well, it is not too smart. 
%
% #1: the style to export.
% #2: either empty or the fully qualified name of a code key. If #2 is not empty,
% the current value of the code key is remembered. It will be restored
% just before the exported \tikz statement is invoked, and \tikz[#2]
% will be called. The code key should not rely on any arguments (it
% won't be given any)
%
% The exported routine autodetects whether the result is used inside of
% a picture. In that case, the '#2' style will be set inside of a
% scope instead of \tikz[#2].
% 
% Assembles a macro \pgfplotsretval which, upon execution, draws the
% plot style.
%
% As a side effect, it returns the resulting plot style (nothing else) into
% \pgfplotsretvalb
\def\pgfplots@export@legend@image@to@macro#1#2{%
	\begingroup
	% I'd like to get all options which are INDEPENDENT of
	% pgfplots. Idea: expand all /pgfplots-keys and collect
	% everything which belongs NOT to /pgfplots. This is the
	% completely expanded rest. At least, I hope so and it appears
	% to work.
	%
	% FIXME : this was a good approach before. Now, there ARE
	% /pgfplots keys which should be maintained. How shall I do that?
	% I can't handle every option separately... !?
	\pgfkeysinstallkeyfilter
		{/pgf/key filters/and}
			{{/pgf/key filters/is descendant of=/pgfplots}%
			 {/pgf/key filters/defined}}%
	\def\pgfplots@label@tikzopts{}%
	\pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@label@tikzopts}%
	\pgfqkeysfiltered{/tikz}{#1}%
	%
	\pgfkeysgetvalue{/pgfplots/legend image code/.@cmd}{\pgfplots@curlegendcode}%
	\pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler
	\toks0=\expandafter{\pgfplots@curlegendcode\pgfeov}%
	\toks1=\expandafter{\pgfplots@label@tikzopts}%
	\toks3=\expandafter{\pgfplots@basiclevel@plothandler}%
	\def\pgfplots@stylekey{#2}%
	\ifx\pgfplots@stylekey\pgfutil@empty
	\else
		\pgfkeysgetvalue{\pgfplots@stylekey/.@cmd}{\pgfplots@stylekey@}%
		\toks4=\expandafter{\pgfplots@stylekey@\pgfeov}%
	\fi
	\edef\pgfplots@loc@TMPa{%
		{%
			\ifx\pgfplots@stylekey\pgfutil@empty
			\else
				\noexpand\scope[#2]%
			\fi
			%
			\noexpand\pgfplots@draw@image
			%
			\ifx\pgfplots@stylekey\pgfutil@empty
			\else
				\noexpand\endscope%
			\fi
		}{%
			\noexpand\tikz[#2]{%
				\noexpand\pgfplots@draw@image
			}%
		}%
	}%
	\expandafter\pgfplots@assemble@ref@picture\pgfplots@loc@TMPa
	\toks5=\expandafter{\pgfplotsretval}%
	%
	\edef\pgfplotsretval{%
		\noexpand\begingroup
		\noexpand\def\noexpand\pgfplots@draw@image{%
			\noexpand\def\noexpand\tikz@plot@handler{\the\toks3}%
			\noexpand\pgfkeysdef{/pgfplots/legend image code}{\the\toks0}%
			\ifx\pgfplots@stylekey\pgfutil@empty
			\else
				\noexpand\pgfkeysdef{#2}{\the\toks4}%
			\fi
			\noexpand\pgfplots@show@small@legendplots{\the\toks1}{}%
		}%
		\the\toks5
		\noexpand\endgroup%
	}%
	\xdef\pgfplots@glob@TMPa{\the\toks1}%
	\pgfmath@smuggleone\pgfplotsretval
	\endgroup
	\let\pgfplotsretvalb=\pgfplots@glob@TMPa
}%

% The implementation for \label{foo} after \addplot. It allows to
% \ref{foo} (it inserts the 'legend image code').
%
% With 
% \addplot[scatter/classes={a={}}] ... ;
% \label[a]{my label}  
% you can reference scatter/classes labels.
%
% I only need to overwrite '\label'; the rest is done by LaTeX.
%
% THIS IS INCOMPATIBLE WITH plain TeX and ConTeXt! Don't use it, it
% doesn't hurt.
\def\pgfplots@plot@label{\pgfutil@ifnextchar[{\pgfplots@plot@label@}{\pgfplots@plot@label@[]}}%
\def\pgfplots@plot@label@[#1]#2{%
	\ifpgfplots@has@label@information
		\begingroup
		\expandafter\let\expandafter\pgfplots@loc@TMPb\csname pgfplots@last@plot@style@#1\endcsname
		\expandafter\pgfplots@export@legend@image@to@macro\expandafter{\pgfplots@loc@TMPb}{/pgfplots/every crossref picture}%
		%
		\t@pgfplots@toka=\expandafter{\pgfplotsretval}%
		\t@pgfplots@tokb=\expandafter{\pgfplotsretvalb}%
		% 1. prepare /pgfplots/refstyle={#2}:
		\pgfplots@auxwrite{%
			\noexpand\expandafter\noexpand\gdef
			\noexpand\csname pgfplots@labelstyle@#2\noexpand\endcsname{\the\t@pgfplots@tokb}%
		}%
		% 2. prepare \ref{#2} and \pageref{#2}:
		%
		% There are several nasty things to consider:
		% a) macro expansion. Use \string to allow a safe \write
		% operation.
		%
		% b) \protect . If the resulting \ref{} command occurs within
		% a "moving argument" like \caption or so, we need to use
		% proper '\protect'ion. 
		%
		% this here is the low-level implementation of \ref{#2}. Write it into
		% the .aux file:
		\pgfplots@auxwrite{%
			\noexpand\expandafter\noexpand\gdef
			\noexpand\csname pgfplots@show@ref@#2\noexpand\endcsname{%
				\the\t@pgfplots@toka
			}%
		}%
		% create the \label command:
		\let\label=\pgfplots@original@LaTeX@label
		\pgfplots@label{#2}{pgfplots@show@ref@}%
		\endgroup
	\else
		\pgfplots@error{Can't create \string\label{#2}: it needs to be called after \string\addplot.}%
	\fi
}%


\def\pgfplots@interruptdatabb{\pgfplots@bb@isactivefalse}
\def\endpgfplots@interruptdatabb{\pgfplots@bb@isactivetrue}

% A helper method which defines 
%  `/tikz/current plot style' to be {#1}  --- with properly set key
%  search paths.
\def\pgfplots@define@currentplotstyle@as#1{%
	\pgfkeysdef{/tikz/current plot style}{%
		% make sure the search path is set.
		% Inside of an axis, this is already ok.
		\pgfkeysifdefined{/pgfplots/.unknown/.@cmd}%
			{\relax}% search path in /pgfplots is already set
			{%
%\message{DEBUG: re-initializing /pgfplots/.search also=/tikz  in current plot style!}%
				\pgfkeysalso{/pgfplots/.search also=/tikz}%
			}%
		%
		% Make sure that 
		% \addplot[every mark/.append style={...}]
		% or something like that is interpreted as /tikz/ key:
		\pgfplots@invoke@pgfkeyscode{/handler config/full or existing/.@cmd}{}% restrict
		%
		\pgfkeysdef{/pgfplots/colorbar source}{}% make it NO-OP here. It has already been processed.
		%
		% set both, pgfplots and tikz keys:
		% the draw is important since \addplot visualizes its stuff
		% with \path coordinates ...
		% -> we need to activate draw mode here.
		\pgfplotsset{/tikz/draw,#1}%
		\pgfplots@invoke@pgfkeyscode{/handler config/all/.@cmd}{}% unrestrict
		%
		% remember these technical things: they will be
		% reset in \path (see below!), so we will need to re-activate
		% them.
		% The re-activation is done in 'every path' (see below).
		% FIXME : is that portable!?
		\pgfplots@assert@tikzinternal@exists{tikz@options}%
		\pgfplots@assert@tikzinternal@exists{tikz@mode}%
		\let\pgfplots@drawoptions=\tikz@options
		\let\pgfplots@drawmodes=\tikz@mode
		%
		% As of February 22, the final plot processing uses
		% foreach stored \addplot command :
		%   \scope[current plot style]
		%   <finalize coord stream>
		%   \draw <finalized coord stream>
		%   \endscope
		% -> the problem: \draw reset the modes 'draw,fill' etc which
		%  have been set in \scope!
		% -> ad-hoc-solution:
		%    restore the modes manually.
		%
		% This is done here. The \pgfplots@drawmodes is ONLY set
		% inside of this scope, so we can check for that particular
		% case:
		\pgfkeys{/tikz/every path/.append code={%
			\pgfutil@ifundefined{pgfplots@drawmodes}%
				{\relax}%
				{%
					\let\tikz@mode=\pgfplots@drawmodes
%					\let\tikz@options=\pgfplots@drawoptions
				}%
			}%
		}%
	}%
}%

% Invokes #1 if the statement occurs within \begin{axis}...\end{axis}
% and #2 if not.
\long\def\pgfplotsifinaxis#1#2{%
	\pgfutil@ifundefined{pgfplots@is@in@axis}{#2}{#1}%
}%

\pgfutil@ifundefined{label}{\relax}{%
}%

%
% \begin{axis}[#1] :
%
% This command prepares the axis for collection. NOTHING will be drawn
% until \end{axis}. During the collect phase, axis limits will be
% computed.
%
% The following variables are accummulated between 
% \begin{axis}
% and
% \end{axis}:
%
% -  \pgfplots@[xyz]min
%    \pgfplots@[xyz]max
%    	- These denote the axis limits. 
%    	- They are always assigned globally.
%    	- For linear axes, they will be computed in floating point.
%    	- For log axes, they will be computed using pgf math engine.
% - \pgfplots@[xyz]min@reg
%   	- A register containing the value of macro \pgfplots@[xyz]min
%   	in pt. It is only valid during \end{axis}.
% - \pgfplots@[xyz]max@reg
%   	- The same for 'max'.
% - \pgfplots@invalidrange@[xyz]min
%   \pgfplots@invalidrange@[xyz]max
%   \pgfplots@invalidrange@meta[max,min]
%   	A value which is used for the axis limits before the
%   	limit computation starts.
% - \pgfplots@data@[xyz]min
%   \pgfplots@data@[xyz]max
%   	- DATA limits. These limits are not affected by limit
%   	restrictions
%   	- They are used to initialise the data scaling trafo.
%   	- They WON'T be assigned for log axes.
%   	- Assigned globally.
% - \pgfplots@[xyz]min@unscaled@as@float
%   	- Assigned during \end{axis} (local variables).
%   	- Contain the value of axis limits as floating point numbers
%   	in the original data range.
% - \pgfplots@metamin
%   \pgfplots@metamax
%   \pgfplots@axiswide@metamin
%   \pgfplots@axiswide@metamax
%   	- if meta data is active, these macros will contain the upper
%   	and lower bound for meta data, the first two on a per-plot
%   	basis the latter to globally for the complete axis.
%   	- will be assigned globally.
%   	- meta data is ALWAYS collected in floating point.
% - \pgfplots@colorbar@src@metamin
% - \pgfplots@colorbar@src@metamax
%   	- these keys are usually empty, unless one provides the
%   	'colorbar source' key for an \addplot command. In that case,
%   	they will be filled (globally) with the point meta min/max
%   	ranges of that particular plot. The colorbar will use the
%   	result for its ranges.
% - \pgfplots@numplots
%   	- A count register indexing the current plot counter. Assigned
%   	globally.
% - \ifpgfplots@apply@datatrafo
%   	A boolean which indicates whether any scaling trafo is
%   	active.
% - \ifpgfplots@apply@datatrafo@[xyz]
%   	Booleans indicating whether for which axes the scaling trafo
%   	is active.
% - \pgfplots@stored@plotlist
%   	- An instance of pgfplotslist.
%   	- It is assigned globally.
%   	- Every \addplot or tikz path command is collected into this
%   	structure.
%   	- The element type is a compound object containing everything
%   	needed to process the plot during \end{axis}.
% - \pgfplots@plotspeclist
%   	- instance of pgfplotslist
%   	- collects every line specification for \addplot.
%   	- Used to assemble legends.
%   	- Assigned globally.
% - \pgfplots@legend
%   	- instance of pgfplotslist
%   	- collects every legend entry.
%   	- Used to assemble legends.
%   	- Assigned globally.
% - \pgfplots@data@scale@trafo@SHIFT@[xyz]
%   \pgfplots@data@scale@trafo@EXPONENT@[xyz]
%   	- For any direction for which the scaling trafo is active,
%   	these macros contain the two parameters for the affine scaling
%   	trafo.
% - \pgfplots@firstplot@coords@[xyz]
%   	- A macro containing a comma separated list
%   	- It is collected if and only if [xyz]tick = 'data'.
%   	- Contains a list of coordinates in floating point
%   	representation if the axis is linear.
%   	- The coordinates are in pgf math notation for log axes.
%   	- Assigned globally.
% - \pgfplots@[xyz]@veclength
%   	- A macro containing the vector length of the [xyz] unit
%   	vector.
%   	- Assigned in \end{axis}
% - \pgfplots@[xyz]@inverseveclength
%   	- A macro containing the INVERSE vector length of the [xyz]
%   	unit vector.
%   	- Assigned in \end{axis}
% - \pgfplotspoint[xyz]axis
%   	- A macro which sets 'pgf@x' and 'pgf@y' to the [xyz] axis.
% - \pgfplotspoint[xyz]axislength
%   	- A macro containing the vector length of the [xyz] axis
%   	(including the 'pt' suffix).
%
% - \ifpgfplots@curplot@threedim
%   	- valid during an '\addplot' preparation step. 
% - \ifpgfplots@threedim
%   	- whether the axis shall be threedimensional.
%
% - \pgfplots@currentplot@firstcoord@[xyz] 
% - \pgfplots@currentplot@lastcoord@[xyz]
%   	- contains the first/last coordinate of the current plot.
%   	- assigned globally.
% - \ifpgfplots@coord@stream@isfirst
%   	- assigned globally during \addplot.
% - \pgfplotssurveyphase@setactiveplothandlers
%   	A macro which is used to implement '\numplotsofactualtype'
%   	see \pgfplots@countplots@advance for details.
%
%
\def\pgfplots@environment@opt[#1]{%
	\begingroup
	\pgfutil@ifundefined{pgfplots@is@in@axis}{}{%
		\pgfplots@error{%
			Sorry, nested axis environments are not supported.
			Please move the inner axis environment below \string\end{axis} and
			use alignment options (for example named nodes, see manual) to place it at the desired
			position}%
	}%
	\def\pgfplots@is@in@axis{1}%
	\pgfplots@checkandpreparefor@active@semicolon
	\pgfplots@install@abbrev@commands
	\pgfplots@stacked@initialise
	%
	%
	% The explicit specification of 'x' and 'y' as 1pt is to avoid
	% numeric overflow/underflow during scale computations:
	%
	% The scaling (i.e. proper values for 'x' and 'y') will be
	% determined later-on, dependend on the axis limits.  Since axis
	% limits are implicitly in units of 1pt, it is reasonable to use
	% '1pt' here as well.
	\pgfsetxvec{\pgfqpoint{1pt}{0pt}}%
	\pgfsetyvec{\pgfqpoint{0pt}{1pt}}%
	\pgfsetzvec{\pgfqpoint{0pt}{0pt}}%
	%
	\pgfplots@set@options{#1}%
	%
	% --------------------
	% Allocations:
	% --------------------
	\pgfplots@init@cleared@structures
	%
	% --------------------
	% Option preprocessing
	% --------------------
	\pgfplots@prepare@coord@filtering@for x%
	\pgfplots@prepare@coord@filtering@for y%
	\pgfplots@prepare@coord@filtering@for z%
	\ifpgfplots@apply@datatrafo
		\pgfplots@datascaletrafo@initialisedfalse
	\else
		\pgfplots@datascaletrafo@initialisedtrue% there is no trafo.
	\fi
	%
	\ifpgfplots@xislinear
		\pgfmathfloatcreate{1}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@xmin=\pgfmathresult
		\pgfmathfloatcreate{2}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@xmax=\pgfmathresult
	\else
		\def\pgfplots@invalidrange@xmin{16300}%
		\def\pgfplots@invalidrange@xmax{-16300}%
	\fi
	\ifpgfplots@yislinear
		\pgfmathfloatcreate{1}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@ymin=\pgfmathresult
		\pgfmathfloatcreate{2}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@ymax=\pgfmathresult
	\else
		\def\pgfplots@invalidrange@ymin{16300}%
		\def\pgfplots@invalidrange@ymax{-16300}%
	\fi
	\ifpgfplots@zislinear
		\pgfmathfloatcreate{1}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@zmin=\pgfmathresult
		\pgfmathfloatcreate{2}{1.0}{2147483645}%
		\let\pgfplots@invalidrange@zmax=\pgfmathresult
	\else
		\def\pgfplots@invalidrange@zmin{16300}%
		\def\pgfplots@invalidrange@zmax{-16300}%
	\fi
	\pgfmathfloatcreate{1}{1.0}{2147483645}%
	\let\pgfplots@invalidrange@metamin=\pgfmathresult
	\pgfmathfloatcreate{2}{1.0}{2147483645}%
	\let\pgfplots@invalidrange@metamax=\pgfmathresult
	%
	% These numbers will ONLY be filled for linear axis!
	\global\let\pgfplots@data@xmin=\pgfplots@invalidrange@xmin
	\global\let\pgfplots@data@xmax=\pgfplots@invalidrange@xmax
	\global\let\pgfplots@data@ymin=\pgfplots@invalidrange@ymin
	\global\let\pgfplots@data@ymax=\pgfplots@invalidrange@ymax
	\global\let\pgfplots@data@zmin=\pgfplots@invalidrange@zmin
	\global\let\pgfplots@data@zmax=\pgfplots@invalidrange@zmax
	\global\let\pgfplots@axiswide@metamin=\pgfplots@invalidrange@metamin
	\global\let\pgfplots@axiswide@metamax=\pgfplots@invalidrange@metamax
	\global\let\pgfplots@colorbar@src@metamin=\pgfutil@empty
	\global\let\pgfplots@colorbar@src@metamax=\pgfutil@empty
	%
	\pgfplots@autocompute@all@limitstrue
	\ifx\pgfplots@xmin\pgfutil@empty
		\pgfplots@autocompute@xmintrue
		\global\let\pgfplots@xmin=\pgfplots@invalidrange@xmin
	\else
		\pgfplots@autocompute@all@limitsfalse
	\fi
	\ifx\pgfplots@xmax\pgfutil@empty
		\pgfplots@autocompute@xmaxtrue
		\global\let\pgfplots@xmax=\pgfplots@invalidrange@xmax
	\else
		\pgfplots@autocompute@all@limitsfalse
	\fi
	\ifx\pgfplots@ymin\pgfutil@empty
		\pgfplots@autocompute@ymintrue
		\global\let\pgfplots@ymin=\pgfplots@invalidrange@ymin
	\else
		\pgfplots@autocompute@all@limitsfalse
	\fi
	\ifx\pgfplots@ymax\pgfutil@empty
		\pgfplots@autocompute@ymaxtrue
		\global\let\pgfplots@ymax=\pgfplots@invalidrange@ymax
	\else
		\pgfplots@autocompute@all@limitsfalse
	\fi
	\ifx\pgfplots@zmin\pgfutil@empty
		\pgfplots@autocompute@zmintrue
		\global\let\pgfplots@zmin=\pgfplots@invalidrange@zmin
	\else
		\global\pgfplots@threedimtrue
		\pgfplots@autocompute@all@limitsfalse
	\fi
	\ifx\pgfplots@zmax\pgfutil@empty
		\pgfplots@autocompute@zmaxtrue
		\global\let\pgfplots@zmax=\pgfplots@invalidrange@zmax
	\else
		\global\pgfplots@threedimtrue
		\pgfplots@autocompute@all@limitsfalse
	\fi
	%
	% check for axis-wide 'point meta min' :
	\pgfkeysgetvalue{/pgfplots/point meta min}\pgfplots@loc@TMPa
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\def\pgfplots@axiswide@metamin@autocompute{1}%
	\else
		\def\pgfplots@axiswide@metamin@autocompute{0}%
		\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
		\global\let\pgfplots@axiswide@metamin=\pgfmathresult
	\fi
	\pgfkeysgetvalue{/pgfplots/point meta max}\pgfplots@loc@TMPa
	\ifx\pgfplots@loc@TMPa\pgfutil@empty
		\def\pgfplots@axiswide@metamax@autocompute{1}%
	\else
		\def\pgfplots@axiswide@metamax@autocompute{0}%
		\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}%
		\global\let\pgfplots@axiswide@metamax=\pgfmathresult
	\fi
	%
	% --------------------
	% Start axis:
	% start survey phase!
	% --------------------
	%
	\ifpgfplots@stackedmode
	\else
		% we have no stacked plots and thus no reversing.
		\pgfplots@stacked@reversefalse
	\fi
	%
	\pgfutil@ifundefined{label}{\relax}{%
		\let\pgfplots@original@LaTeX@label=\label
		\let\label=\pgfplots@plot@label
	}%
	%
	\global\pgfplots@has@label@informationfalse
	%
	\def\numplots{\the\pgfplots@numplots}%
	\global\let\pgfplotssurveyphase@setactiveplothandlers=\pgfutil@empty
	\let\numplotsofactualtype=\pgfplots@numplotsofactualtype
	%
	% any \path command is invalid inside of an axis.
	% Use \axispath instead:
	\let\path=\pgfplots@replacement@for@tikz@path
	\let\closedcycle=\pgfplots@path@closed@cycle
	\let\pgfplots@orig@scope=\scope
	\let\pgfplots@orig@endscope=\endscope
	\let\scope=\pgfplots@replacement@for@scope
	\let\endscope=\pgfplots@replacement@for@endscope
	%
}

% \end{axis} :
%
% This command actually takes all collected (global) variables,
% creates an axis and performs all postponed drawing operations.
\def\endpgfplots@environment@opt{%
	\pgfutil@ifundefined{label}{\relax}{%
		% restore.
		\let\label=\pgfplots@original@LaTeX@label
	}%
	\xdef\numplots{\the\pgfplots@numplots}%
	\pgfkeysvalueof{/pgfplots/before end axis/.@cmd}\pgfeov%
	%
	% restore old \path command:
	\let\path=\pgfplots@orig@path
	\let\plot=\pgfplots@orig@plot
	\let\scope=\pgfplots@orig@scope
	\let\endscope=\pgfplots@orig@endscope
	%
	\pgfplotssurveyphase@setactiveplothandlers
	%
	%\end{axis}:
	%
	% create a leight-weight 'current axis' node for anchor references
	% (which may happen during both, the axis descriptions or any
	% path/plot commands). 
	\pgfmultipartnode{pgfplots@low@level@shape@INNER}{image}{current axis}{\pgfusepath{discard}}%
	%
	% --------------------
	%  All plotting commands have been read.
	%  -> apply postponed drawing commands!
	% --------------------
	\pgfplots@BEGIN@init@and@draw@axis
	\pgfplots@stacked@initialise
	\pgfplots@install@local@bar@handlers
	\global\pgfplotslistnewempty\pgfplots@stored@markerlist
	\ifpgfplots@stacked@reverse
		% This here applies any scaling trafos and assembles a
		% NEW \pgfplots@stored@plotlist!
		\pgfplots@stacked@finalize@stored@plots
	\fi
	\pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{%
		\expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa
%\message{Processing stored plot with precommand '\meaning\pgfplots@stored@current@precmd';  pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd' postcommand '\meaning\pgfplots@stored@current@postcmd'}%
		% The precmd sets all required variables needed to
		% finalize a plot.
		% @see the stream preparation routines.
		\pgfplots@stored@current@precmd
		\ifx\pgfplots@stored@current@cmd\pgfutil@empty
			\pgfplots@stored@current@data%
		\else
			%
			% this code here means we REALLY have a plotting
			% command!
			\scope[current plot style] % this does set BOTH pgfplots and tikz options.
			%
			% de-activate the FPU here! I fear its number
			% format may cause errors when used in low-level
			% routines.
			\pgfkeys{/pgf/fpu=false}%
			%
			\ifpgfplots@stacked@reverse
				% has already been processed above, in \pgfplots@stacked@finalize@stored@plots.
				\pgfplots@stacked@draw@reversed@plot
			\else
				% modifies \pgfplots@stored@markerlist if necessary.
				\expandafter\pgfplots@coord@stream@finalize@storedcoords@START\pgfplots@stored@current@data\pgfplots@EOI
			\fi
			\endscope
		\fi
		\pgfplots@stored@current@postcmd
	}%
	\global\pgfplotslistnewempty\pgfplots@stored@plotlist% delete contents.
	%
	\pgfplots@END@init@and@draw@axis
	%
	\pgfplots@create@axis@descriptions
	%
	\endtikzpicture%
	\begingroup
		% Protocol sizes for the axis-shape.
		% That needs to be done globally, do avoid all those
		% \endgroup's in and after \endpgfinterruptpicture ...
		\ifdim\pgf@picmaxx=-16000pt\relax%
			\pgf@picmaxx=0pt\relax%
			\pgf@picminx=0pt\relax%
			\pgf@picmaxy=0pt\relax%
			\pgf@picminy=0pt\relax%
		\fi%
		%
		\xdef\pgfplots@saveddimen@picminx{\the\pgf@picminx}%
		\xdef\pgfplots@saveddimen@picminy{\the\pgf@picminy}%
		%
		\ifpgfplots@deprecated@anchors
			\pgfplotspointminminmin
		\else
			\pgfplotspointbblowerleft
		\fi
		\pgf@xa=\pgf@x
		\advance\pgf@xa by-\pgf@picminx
		\xdef\pgfplots@savedanchor@inner@lowerleft@x{\the\pgf@xa}%
		%
		\pgf@xa=\pgf@y
		\advance\pgf@xa by-\pgf@picminy
		\xdef\pgfplots@savedanchor@inner@lowerleft@y{\the\pgf@xa}%
		%
		\pgfplotspointaxisorigin
		\global\advance\pgf@x by-\pgf@picminx
		\global\advance\pgf@y by-\pgf@picminy
		\xdef\pgfplotspointaxisorigin{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}%
	\endgroup
	\endpgfinterruptpicture
	\egroup\egroup% end of pgfnodepartimagebox
	%
	\let\tikz@fig@name=\pgfplots@fig@name
	\tikz@fig@mustbenamed
	%
	% restore any shift transformations provided to an axis.
	% These would be lost otherwise.
	\pgftransformshift{\pgfplots@savedtransformshift}%
	%
	% allow positioning of colorbars with this hook.
	% It is \relax unless this here is a color bar axis.
	% Its intention is to re-define `\pgfplots@at':
	\pgfplots@colorbar@position@hook%
	%
    \pgftransformshift{\pgfplots@at}%
	%
	\edef\pgfplots@shapename{pgfplots@low@level@shape\ifpgfplots@deprecated@anchors @deprecated\fi}%
	\pgfutil@ifundefined{pgf@anchor@\pgfplots@shapename @\pgfplots@anchorname}{%
		% Oh. Well, suppose \pgfplots@anchorname is associated to an
		% INNER node.
		\def\pgfplots@loc@TMPa##1{%
			\pgftransformshift{%
				% So far, the inner node's position has not been
				% corrected (that happens in 
				% \pgfplots@finally@correct@child@node@positions).
				% Do that here with \pgfplots@saveddimen@picminx:
				\pgfpointdiff
					{\pgfqpoint{\pgfplots@saveddimen@picminx}{\pgfplots@saveddimen@picminy}}
					{##1}%
				\global\pgf@x=-\pgf@x \global\pgf@y=-\pgf@y
			}%
		}%
		\expandafter\tikz@scan@one@point\expandafter\pgfplots@loc@TMPa\expandafter(\pgfplots@anchorname)%
		\def\pgfplots@anchorname{image}% that means: no shift!
	}{}%
	%
	\ifpgfplots@deprecated@anchors
		\pgfplots@restore@deprecated@lowlevel@shape
		\pgfmultipartnode{\pgfplots@shapename}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}%
	\else
		\pgfmultipartnode{\pgfplots@shapename}{\pgfplots@anchorname}{\tikz@fig@name}{\pgfusepath{discard}}%
	\fi
	\pgfplots@fig@alias
	\pgfnodealias{current axis}{\tikz@fig@name}%
	%
	\pgfplots@finally@correct@child@node@positions
	\pgfplots@stacked@finalize
	%
	\ifpgfplots@colorbar
		\pgfplots@colorbar@move@outside@scope@with@globalmacro{\pgfplots@glob@TMPa}%
	\else
		\global\let\pgfplots@glob@TMPa=\relax
	\fi
	\endgroup
	\pgfplots@glob@TMPa
}

% Now, we need to process all named nodes inside of our
% axis-image.
%
% The situation at this point is as follows:
% 1. the complete axis image has been "typeset" into a box. That
% means its coordinate system is LOST up to those variables
% which have been saved explicitly.
%
% 2. the \pgfmultipartnode above knows about all axis anchors and
% saved dimensions.
%
% 3. All sub-nodes don't know about their position any more. Any
% saved anchors are wrong.
%
% The approach:
% 1. we shift each named node's saved anchors such that it's
% coordinate is valid inside of the TeX box.
%
% 2. we also shift each named node's saved anchors to reflect the
% axis' anchor.
%
% Afterwards, everything should be fine.
\def\pgfplots@finally@correct@child@node@positions{%
   \ifx\pgfplots@named@child@node@list\pgfutil@empty%
   \else%
      	\begingroup
		\pgftransformreset% FIXME: what's that for!? Copied from matrix code...
		%
		% Use the 'image' anchor here - the internal anchor
		% transformation matrix already has the shift for
		% \pgfplots@anchorname.
		\pgfpointanchor{\tikz@fig@name}{image}%
		\pgf@xa=\pgf@x
		\pgf@xb=\pgf@y
		\pgf@process{\pgfqpoint{\pgfplots@saveddimen@picminx}{\pgfplots@saveddimen@picminy}}%
		\advance\pgf@xa by-\pgf@x
		\advance\pgf@xb by-\pgf@y
		\global\pgf@x=\pgf@xa
		\global\pgf@y=\pgf@xb
		\edef\pgfplots@offset{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}}%
		%
		\pgfutil@for\pgfplots@child@node@name:=\pgfplots@named@child@node@list\do{%
			\ifx\pgfplots@child@node@name\pgfutil@empty
			\else
%\message{Attempting to correct  '\pgfplots@child@node@name' position by \meaning\pgfplots@offset\space (the node is inside of an axis).}%
				\expandafter\ifx\csname pgfplots@child@node@visited@\pgfplots@child@node@name\endcsname\relax%
					\pgfutil@ifundefined{pgf@sh@nt@\pgfplots@child@node@name}{%
						\pgfplots@warning{could not adjust coordinates of named node '\pgfplots@child@node@name' for reasons I do not understand! After finishing the image, it did no longer exist!? Sorry.}%
					}{%
						\pgf@shift@node{\pgfplots@child@node@name}{\pgfplots@offset}%
						\expandafter\let\csname pgfplots@child@node@visited@\pgfplots@child@node@name\endcsname=\pgfutil@empty%
					}%
				\fi
			\fi
		}%
		\endgroup
    \fi%
}%

\def\pgfplots@environment@axis{%
	\pgfutil@ifnextchar[{\pgfplots@@environment@axis}{\pgfplots@@environment@axis[]}%
}
\def\endpgfplots@environment@axis{\endpgfplots@environment@opt}
\def\pgfplots@@environment@axis[#1]{%
	\pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=linear,#1]%
}

\def\pgfplots@environment@semilogxaxis{%
	\pgfutil@ifnextchar[{\pgfplots@@environment@semilogxaxis}{\pgfplots@@environment@semilogxaxis[]}%
}
\def\endpgfplots@environment@semilogxaxis{\endpgfplots@environment@opt}
\def\pgfplots@@environment@semilogxaxis[#1]{%
	\pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=linear,#1]%
}

\def\pgfplots@environment@semilogyaxis{%
	\pgfutil@ifnextchar[{\pgfplots@@environment@semilogyaxis}{\pgfplots@@environment@semilogyaxis[]}%
}
\def\endpgfplots@environment@semilogyaxis{\endpgfplots@environment@opt}
\def\pgfplots@@environment@semilogyaxis[#1]{%
	\pgfplots@environment@opt[/pgfplots/xmode=linear,/pgfplots/ymode=log,#1]%
}

\def\pgfplots@environment@loglogaxis{%
	\pgfutil@ifnextchar[{\pgfplots@@environment@loglogaxis}{\pgfplots@@environment@loglogaxis[]}%
}
\def\endpgfplots@environment@loglogaxis{\endpgfplots@environment@opt}
\def\pgfplots@@environment@loglogaxis[#1]{%
	\pgfplots@environment@opt[/pgfplots/xmode=log,/pgfplots/ymode=log,#1]%
}


\pgfutil@ifundefined{tikzaddtikzonlycommandshortcutlet}{%
	\def\tikzaddtikzonlycommandshortcutlet#1#2{%
		\expandafter\def\expandafter\tikz@installcommands\expandafter{\tikz@installcommands
			\let#1=#2
		}%
	}%
}{}

\tikzaddtikzonlycommandshortcutlet\axis\pgfplots@environment@axis
\tikzaddtikzonlycommandshortcutlet\endaxis\endpgfplots@environment@axis

\tikzaddtikzonlycommandshortcutlet\semilogxaxis\pgfplots@environment@semilogxaxis
\tikzaddtikzonlycommandshortcutlet\endsemilogxaxis\endpgfplots@environment@semilogxaxis

\tikzaddtikzonlycommandshortcutlet\semilogyaxis\pgfplots@environment@semilogyaxis
\tikzaddtikzonlycommandshortcutlet\endsemilogyaxis\endpgfplots@environment@semilogyaxis

\tikzaddtikzonlycommandshortcutlet\loglogaxis\pgfplots@environment@loglogaxis
\tikzaddtikzonlycommandshortcutlet\endloglogaxis\endpgfplots@environment@loglogaxis


\catcode`\;=\pgfplots@oldcatcodesemicolon
